第2个回答 2012-06-15
public static void outputString1(String str, File file) {
try {
out = new PrintWriter(file);
byte bytes[] = str.getBytes();
int i = 0;
while ((bytes.length - i) != 0) {
out.write(bytes[i]);
i++;
}
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
* @param str
* 要写入文件的字符串
* @param file
* 要写入字符串的文件名,如new File("C:/test.doc")