// текстовых файлов,- а также манипуляции файлом как списком ArrayList
package net mindview util;
import java io.*.
import java util *.
public class TextFile extends ArrayList<String> { // Чтение файла как одной строки; public static String read(String fileName) {
StringBuilder sb = new StringBuilderO; try {
BufferedReader in= new BufferedReader(new FileReader(
new Fi1е(fi 1eName).getAbsoluteFi1e()));
try {
String s,
while((s = in readLineO) != null) { sb append(s); sb.append("\n");
}
} finally {
in.closeO;
}
} catch(IOException e) {
throw new RuntimeException(e);
}
return sb toStringO;
}
// Запись файла за один вызов метода: public static void write(String fileName, String text) { try {
PrintWriter out = new PrintWriter(
new FileCfileName).getAbsoluteFileO);
try {
out.print(text); } finally {
out. closeO;
}
} catch(IOException e) {
throw new RuntimeException(e);