📄 filedemo3.java
字号:
/**
*pay more attention to this program!!!
*Byte stream classes through reading from and writing to a file
*2004.11.19. xhcprince
*/
import java.io.*;
class fileDemo3
{
public static void main(String args[]) throws IOException
{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the file name:");
String fname = br1.readLine();
FileOutputStream fo = new FileOutputStream(fname);
BufferedReader br2 = new BufferedReader(new InputStreamReader(System.in));
String s;
System.out.print("Enter the content of the text:");
System.out.flush();//pay attention!To clear the buffer!It's better to write it!
s = br2.readLine();
for(int i=0; i<s.length(); ++i)
fo.write(s.charAt(i));
fo.close();
FileInputStream fi = new FileInputStream(fname);
int read;
System.out.print("\nIn the " + fname + " file: ");
while((read=fi.read()) != -1)
System.out.print((char)read);
fi.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -