import java.io.*;public class Ex{
public static void main(String args[]){
File file = new File("\\tmp.txt");
int i;

try {
//清空文件中的所有内容
FileOutputStream testfile = new FileOutputStream(file);
testfile.write(new String("").getBytes());
testfile.close();

//新建写入流
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(10);
bw.newLine();
bw.write("张望");
bw.newLine();
bw.close();

catch (IOException e1) {
e1.printStackTrace();
} }
}