当前位置:网站首页>Advanced API (character stream & net for beginners)
Advanced API (character stream & net for beginners)
2022-07-03 07:01:00 【Bugxiu_ fu】
Transformation flow :
FileReader-- Character input stream ( Read )
FileWriter-- Character output stream ( write in )
The basic format :
Read :
A character by character reading
FileReader fr = new FileReader(file);
int n = 0;
while((n=fr.read())!=-1){
System.out.println((char)n); Compared to byte stream Even one by one Can also read Chinese
}
fr.close();
Line by line reading : Our chat is also sent line by line It is not a word by word transmission
File file = new File("f:\\ picture \\6.txt");
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String str = null;
while((str = br.readLine())!=null){
System.out.println(str);
}
br.close();
fr.close();
write in
Scanner mys = new Scanner(System.in);
File file = new File("f:\\ picture \\6.txt");
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
while(true){
System.out.println(" Please enter the content you want to save :");
String str = mys.next();
bw.write(str);
bw.flush();// Be sure to remember to flush the buffer
bw.newLine();// A new line
if(str.equals("exit")){
break;
}
}
bw.close();
fw.close();
边栏推荐
- C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
- Practical plug-ins in idea
- Winter vacation work of software engineering practice
- Create your own deep learning environment with CONDA
- 利用C#实现Pdf转图片
- php artisan
- Inno Setup 制作安装包
- IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
- (翻译)异步编程:Async/Await在ASP.NET中的介绍
- vmware虚拟机C盘扩容
猜你喜欢

2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution

Create your own deep learning environment with CONDA

Practice of enterprise ab/testing platform

Application scenarios of Catalan number

SQL implementation merges multiple rows of records into one row

Asynchronous programming: async/await in asp Net

DBNet:具有可微分二值化的实时场景文本检测
![[untitled]](/img/72/4ff9354634342580a135debb58b60e.jpg)
[untitled]

MySQL installation

Software testing learning - the next day
随机推荐
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
CentOS php7.3 installing redis extensions
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Simple understanding of bubble sorting
利用C#实现Pdf转图片
CentOS switches and installs mysql5.7 and mysql8.0
2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
mongodb
Software testing learning - the next day
La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
[LeetCode]404. Sum of left leaves
How to specify the execution order for multiple global exception handling classes
The 10000 hour rule won't make you a master programmer, but at least it's a good starting point
Use the jvisualvm tool ----- tocmat to start JMX monitoring
EasyExcel
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
dataworks自定义函数开发环境搭建
Resttemplate configuration use
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)