⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writefile.java

📁 这是《Java案例精粹150例(上册)》一书配套的源代码。
💻 JAVA
字号:
package javaio;
import java.io.*;

public class WriteFile{
	public static void main(String args[]){
		try{
			String fileName = "out.txt";//指定文件名
			File file = new File(fileName);
			FileOutputStream out = new FileOutputStream(file);//建立输出流
			byte[] b = new byte[1024];
			String str = "Nice to see you again!";
			b = str.getBytes();//String转化为byte[]
			out.write(b);//写入文本内容
		}
		catch(IOException e){
			System.out.println(e.toString());
		}
	}
}
		
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -