2020-01-03-将数据写入本地文件中

一、需求

编写一个程序,将一个电话号码写入文件中。

二、实现

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();
		}
	}

}

发布了90 篇原创文章 · 获赞 284 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_41293896/article/details/103824259