字符串写入文件

2014-11-24 07:28:32 · 作者: · 浏览: 0

package com.zhangry.interview.java;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class WriteFile {

public static void main(String[] args) {
try {
FileOutputStream out = new FileOutputStream("C:\\FileName.txt");
out.write("字符串写入文件".getBytes());
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

}

}
package com.zhangry.interview.java;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class WriteFile {

public static void main(String[] args) {
try {
FileOutputStream out = new FileOutputStream("C:\\FileName.txt");
out.write("字符串写入文件".getBytes());
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

}

}


摘自 张仁阳专栏