//name : osama manzoor qazi
/* Program that deletes all comments from the source code and
saves
the
rest in a text file. */
/* Checked and tested by Abdul Mateen Khan
Very
Good...
*/
import java.io.*;
class mainpro {
public static void main (String args[]) throws =
IOException {
FileInputStream
iFile = new FileInputStream("mainpr~1.jav");
FileOutputStream
oFile = new FileOutputStream("newFile.txt");
char ch1,ch2;
boolean
single=false,multi=false;
ch1=3D(char)iFile.read(); /* Read first character =
*/
do{
ch2=(char)iFile.read(); /* Read next character =
*/
if
((ch1=='/')&&(ch2=='/')) {
single = true;
}
if
((ch1=='/')&&(ch2=='*')) {
multi = true;
}
if
((ch1=='*')&&(ch2=='/')){
multi=false;
ch1=(char)iFile.read();
ch2=(char)iFile.read();
}
if ((single)&&(ch1==' ')) {
single=false;
}
if
(!((single)||(multi))) { /*
Don't write when single or multi-line
oFile.write((byte)ch1); /* =
comments are present. */
System.out.print(ch1);
}
ch1=ch2;
//this will
disappear
}while(iFile.available()!=0);//do
System.in.read();
/*
this will disappear
this will disappear
*/
}
}//end of class