📄 aboutfile.java
字号:
package threeExam;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class AboutFile {
public static void main(String[] args) throws IOException {
// method1();
method2();
}
private static void method2() throws IOException {
OutputStream outputStream = new FileOutputStream("d:\\a.txt");
int[] is = { 1, 2, 3, 4 };
char[] chars = { 'a', 'b', 'c', 'd' };
String[] strings = { "你好", "af" };
// for (char c : chars) {
// outputStream.write(c);
// }
for (String string : strings) {
outputStream.write(string.getBytes());
}
}
private static void method1() throws FileNotFoundException, IOException {
InputStream inputStream = new FileInputStream("d:\\abc.txt");
OutputStream outputStream = new FileOutputStream("d:\\a.txt");
// byte[] bytes = new byte[1];
int i;
while ((i = inputStream.read()) != -1) {
outputStream.write(i);
}
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -