📄 writefile.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 + -