I am so close to dont thanks to previous help in last post. Now all i need is to remove multi-comments and /* */ comments heres my program. Further explanations below and what i need.
CODE
import java.io.*;
import java.util.ArrayList;
public class RemoveText
{
public static void main(String[] args)throws IOException
{
RemoveText Remove = new RemoveText();
Remove.PrintInFile();
}
public static void PrintInFile()throws IOException
{
String Text = null;
Text = new String();
boolean Quotes = false, Comment = false;
ArrayList<String>Line = new ArrayList();
FileReader ReadFile = new FileReader("InFile.txt");
BufferedReader InFile = new BufferedReader(ReadFile);
FileOutputStream OutFile = new FileOutputStream("OutFile.txt");
PrintStream print = new PrintStream(OutFile);
for(int x = 0;(Text = InFile.readLine()) != null; x++)
{
Line.add(Text);
}
for(int x = 0; x < Line.size(); x++)
{
if(((Line.get(x)).indexOf("//") != -1))
{
Line.set(x, (Line.get(x)).substring(0, (Line.get(x)).indexOf("//")));
}
if(((Line.get(x)).indexOf("/*") != -1))
{
if((Line.get(x)).indexOf("*/") != -1)
{
Comment = true;
}
}
}
for(int x = 0; x < Line.size(); x++)
{
print.println(Line.get(x));
}
}
}
Heres the input file before:
CODE
/************************************************************
Gee a line of stars
*/
#include <iostream.h> //whoops comment
#include <string.h>
#include <iomanip.h> //comment line
int main() /* comment for main */
{
int j; /*declares variable */
string name = "Your famous name"; // comment // followed by another line comment
/*
could this be a //
multi-line comment? //*/
cout << "/*\"\"Who are you? \n";
getline(cin,name); // /*
cout << "\\**/*/*/* You entered */*/*/* "<< name << "*/*/*/*\n";
/*think finished, done!*/
return 0;
}//end of main
Ok heres the problem, my program after executed looks like this:
it should get rid of all the comments but does only // not /**/ or multi lined comments

help plz
CODE
/************************************************************
Gee a line of stars
*/
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
int main() /* comment for main */
{
int j; /*declares variable */
string name = "Your famous name";
/*
could this be a
multi-line comment?
cout << "/*\"\"Who are you? \n";
getline(cin,name);
cout << "\\**/*/*/* You entered */*/*/* "<< name << "*/*/*/*\n";
/*think finished, done!*/
return 0;
}
Now this is what it should look like ater program is executed:
[code]
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
int main()
{
int j;
string name = "Your famous name";
cout << "/*\"\"Who are you? \n";
getline(cin,name);
cout << "\\**/*/*/* You entered */*/*/* "<< name << "*/*/*/*\n";
return 0;
}