Запись:try {
BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream("D:\\file.txt")));
out.write("helloWorld!"); out.newLine();
out.close();
} catch (Exception e1) {
e1.printStackTrace();
}
Чтение:try {
BufferedReader out = new BufferedReader(
new InputStreamReader(
new FileInputStream("D:\\file.txt")));
String readLine = out.readLine();
out.close();
System.out.println(readLine);
} catch (Exception e1) {
e1.printStackTrace();
}
|