Hai Implemented a code that will read the 100s of files from a directory.
Each time when i read a file , i will take that file and check the content of the file( i put them in to a List )and compare with the original List and if there is a different, then i update the array List with write function.
this is what i need
but i get error when i run the code, i coul dread only one file, later it stopped. it does not read the second file in the directory.
could any 1 help me o this
the code what i have is given below
Each time when i read a file , i will take that file and check the content of the file( i put them in to a List )and compare with the original List and if there is a different, then i update the array List with write function.
this is what i need
but i get error when i run the code, i coul dread only one file, later it stopped. it does not read the second file in the directory.
could any 1 help me o this
the code what i have is given below
import java.io.File;
import java.io.Buffere dReader;
import java.io.DataInp utStream;
import java.io.FileInp utStream;
import java.io.InputSt reamReader;
public class checkjava {
public static void main(String[] argv) throws Exception {
File dir = new File("E:\\java\ \check");
String[] children = dir.list();
if (children == null) {
System.out.prin tln("does not exist or is not a directory");
}
else {
for (int i = 0; i < children.length ; i++) {
String filename = children[i];
// System.out.prin tln(filename);
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream (filename);
DataInputStream in = new DataInputStream (fstream);
BufferedReader br = new BufferedReader( new InputStreamRead er(in));
String strLine;
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.prin tln (strLine);
}
in.close();
} catch (Exception e){//Catch exception if any
System.err.prin tln("Error: " + e.getMessage()) ;
}
}
}
}
}
import java.io.Buffere dReader;
import java.io.DataInp utStream;
import java.io.FileInp utStream;
import java.io.InputSt reamReader;
public class checkjava {
public static void main(String[] argv) throws Exception {
File dir = new File("E:\\java\ \check");
String[] children = dir.list();
if (children == null) {
System.out.prin tln("does not exist or is not a directory");
}
else {
for (int i = 0; i < children.length ; i++) {
String filename = children[i];
// System.out.prin tln(filename);
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream (filename);
DataInputStream in = new DataInputStream (fstream);
BufferedReader br = new BufferedReader( new InputStreamRead er(in));
String strLine;
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.prin tln (strLine);
}
in.close();
} catch (Exception e){//Catch exception if any
System.err.prin tln("Error: " + e.getMessage()) ;
}
}
}
}
}