当前位置:网站首页>Introduction of transformation flow
Introduction of transformation flow
2022-07-03 07:21:00 【four thousand three hundred and forty-three】
InputStreamReader And OutputStreamWriter It is also a processing flow
package TransformStream;
import org.junit.Test;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class InputStreamReaderTest {
@Test
public void test1() throws IOException {
FileInputStream fis = new FileInputStream("hello2.txt");
// Use the default character set take Data conversion of byte stream ( stay IDEA Medium is the default UTF-8)
InputStreamReader isr = new InputStreamReader(fis);
// Specify character set take Data conversion of byte stream
// InputStreamReader isr = new InputStreamReader(fis,"gbk");
char[] buffer = new char[5];
int len ;
while((len = isr.read(buffer))!=-1){
String str= new String(buffer);
System.out.print(buffer);
}
// Transformation flow is also processing flow , So just close the outer layer
isr.close();
}
}
OutputStreamWriter
// OutputStreamWriter
@Test
public void test2() throws IOException {
FileReader fr = new FileReader("hello2.txt");
FileOutputStream fos = new FileOutputStream("hello3.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos,"gbk");
char[] buffer = new char[5];
int len;
while((len = fr.read(buffer))!=-1){
osw.write(buffer,0,len);
}
fr.close();
osw.close();
}
边栏推荐
- MySQL transaction rollback, error points record
- PAT甲级真题1166
- File links cannot be opened or downloaded in Google browser
- Map interface and method
- Inno setup production and installation package
- 691. Cube IV
- Jeecg data button permission settings
- How to specify the execution order for multiple global exception handling classes
- 20220319
- High concurrency memory pool
猜你喜欢
How to specify the execution order for multiple global exception handling classes
IPv4 address
Sorting, dichotomy
Le Seigneur des anneaux: l'anneau du pouvoir
Interview questions about producers and consumers (important)
Arduino Serial系列函数 有关print read 的总结
Store WordPress media content on 4everland to complete decentralized storage
Use the jvisualvm tool ----- tocmat to start JMX monitoring
Pat grade a real problem 1166
Use of generics
随机推荐
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
TypeScript let与var的区别
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
Laravel frame step pit (I)
Inno Setup 制作安装包
1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
php artisan
[cmake] cmake link SQLite Library
How to specify the execution order for multiple global exception handling classes
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
Margin left: -100% understanding in the Grail layout
【已解决】win10找不到本地组策略编辑器解决方法
MySQL mistakenly deleted the root account and failed to log in
TreeMap
【最详细】最新最全Redis面试大全(50道)
Use the jvisualvm tool ----- tocmat to start JMX monitoring
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
C WinForm framework
CentOS switches and installs mysql5.7 and mysql8.0
SharePoint modification usage analysis report is more than 30 days