Hi ,all..
How can i read more than one java file but ,without repeating the section of bufferedreader in every time i read file!!....so if i have 20 file ...this way is unpractical??
for example:
this code:
public class buffer{
public static void main(String[]args) throws IOException {
String filname1= "C:/filename/filename1";
String filname2= "C:/filename/filename2";
String filname3= "C:/filename/filename2";
try{
FileReader fr = new FileReader((filname1));
BufferedReader br = new BufferedReader(fr);
line = br.readLine();
while (line != null) {
System.out.println(line);
line = br.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
try{
FileReader fr2 = new FileReader((filname2));
BufferedReader br2 = new BufferedReader(fr2);
line = br2.readLine();
while (line != null) {
System.out.println(line);
line = br2.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
try{
FileReader fr3 = new FileReader((filname3));
BufferedReader br3 = new BufferedReader(fr3);
line = br3.readLine();
while (line != null) {
System.out.println(line);
line = br3.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}