Use BufferedReader and FileReader to read from a file
// Read from a file
String fname = "/tmp/x.x";
try{
BufferedReader bf = new BufferedReader(new FileReader(fname));
String s;
while((s = bf.readLine()) != null){
Print.p(s);
}
bf.close();
}catch(IOException e){
e.printStackTrace();
}
Use BufferedWriter and FileWriter to write to a file
// Write to a file
String fname = "/tmp/x.x";
try{
BufferedWriter bw = new BufferedWriter(new FileWriter(fname));
bw.write("123\n");
bw.close();
}catch(IOException io){
e.printStackTrace();
}