?? 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 + -