一、需求
编写一个程序,将一个电话号码写入文件中。
二、实现
package com.eleven.csdn0103;
import java.io.File;
import java.io.FileOutputStream;
/**
* 编写一个程序,将一个电话号码写入文件中。
*
* @author sywangu
*
*/
public class Phone {
public static void main(String[] args) throws Exception {
File file = new File("d:\\phone.txt");
FileOutputStream outputStream;
try {
outputStream = new FileOutputStream(file);
outputStream.write("13412341234".getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}