Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  cd
Language: JAVA
Code:


import java.io.BufferedReader;

import java.io.DataInputStream;

import java.io.InputStreamReader;

import java.io.IOException;

import java.io.File;

//import java.io.FileFilter;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.BufferedWriter;

public class commdel {





          Public static void main(String args[]){

               

               try{

          

                  File f1 = new File("C:/test/test.txt");

                    BufferedReader in = new BufferedReader(new FileReader(f1));

                    File f2 = new File("C:/test/output.txt");

                    BufferedWriter out = new BufferedWriter(new FileWriter(f2));

                    String s="";

                    int lineCount=0;

                    while ((s=in.readLine())!=null){

                         if (s != null&& s.indexOf("/*") > -1)

                         {

                              while(s != null&&s.indexOf("*/") == -1)

                                   s=in.readLine();

                         }

                         if (s != null

                                   && s.indexOf("/*") == -1

                                   && s.indexOf("*/") == -1

                                   && s.indexOf("//") == -1

                                   && s.length() > 0)

                         {

                         out.write(s);

                         out.newLine();

                         System.out.println(s);

                         lineCount++;               }

                    }

                    System.out.println("Number of lines read = "+lineCount);

                    

               

                    in.close();  

                  out.close();

                    }

               

               catch(IOException e){

                    System.out.println("I/O Error occurred");

               }

          }

     }



Comments: