来源:网络 | 2007-3-8 | (有5148人读过)
以下为Jsp读取文本文件的部分代码,用到的class可以在api中看看
public static void fileWriteLine(String file, String text) throws IOException {
PrintWriter out = new PrintWriter(new FileWriter(file));
out.print(text);
out.close();
}
public static StringBuffer fileReadLine(String file) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(file));
String record = new String();
StringBuffer sb = new StringBuffer();
while ((record = br.readLine()) != null) {
sb.append(record);
}
br.close();
return sb;
}
|