for example below
Example code for read file line by line with Java
FileInputStream fs = new FileInputStream("filename.txt");
DataInputStream ds = new DataInputStream(fs);
BufferedReader br = new BufferedReader(new InputStreamReader(ds));
String tmp;
while ((tmp = br.readLine()) != null) {
System.out.println (tmp);
}
ds.close();
DataInputStream ds = new DataInputStream(fs);
BufferedReader br = new BufferedReader(new InputStreamReader(ds));
String tmp;
while ((tmp = br.readLine()) != null) {
System.out.println (tmp);
}
ds.close();
Example code for Write file with java
FileWriter fw = new FileWriter("file_name.txt");
BufferedWriter out = new BufferedWriter(fw);
out.write("Test Wrrite1");
out.write("Test Wrrite2");
out.write("Test Wrrite3");
out.close();