- Bytearrayinputstream and Bytearrayoutputstream memory streams, operations basic and file flow other streams almost, mainly used in the program need to use temporary files, close the memory stream is invalid so do not shut down
- Operation Flow, no matter what the flow, the safest way is to close it all at last
- Memory streams: Bytearrayinputstream, Bytearrayoutputstream, CharArrayReader, Chararraywriter:
- Print Flow:
| 123456 |
PrintStream: print(Object o); println();println(Object o); printf(String format,Object ... args); //%格式 : s表示字符串, c表示字符, d表示十进制整数, o表示八进制整数,x表示十六进制整数 |
PrintWriter: Unlike the PrintStream class, if Auto-refresh is enabled, it is possible to do this only if one of the methods of println, printf, or format is called, rather than when the line break is output exactly
- System: Redirect for stream:
Two standard streams:
(1) standard input stream
| 1 |
InputStream in = System.in; //默认指的是键盘录入的数据 |
(2) standard output stream
| 1 |
OutputStream out = System.out; //默认指的是屏幕输出; |
Change the source of the standard input stream:
before you call system.in, reassign the source:
| 12 |
System.setIn(新的源); System.setIn(InputStream in); |
To change the target of the standard output stream:
before you call System.out, reassign the target:
| 12 |
System.setOut(新的目标); System.setOut(OutputStream out); |
- Pipe flow: Two threads communicating with each other;
PipedInputStream:
| 1 |
voidconnect(PipedOutputStream src) //使此管道输入流连接到管道输出流 src。 |
PipedOutputStream:
| 1 |
voidconnect(PipedInputStream dest) |
Pipedreader:
| 1 |
voidconnect(PipedWriter src) //使此传送 reader 连接到传送 writer src。 |
PipedWriter:
| 1 |
voidconnect(PipedReader dest) |
- Properties:
| 12 |
voidload(InputStream in);//去加载资源,以流的方式传输 String getProperty(String key, String defaltValue)://根据key找value,其实就是Map里的get(Object key); |
- Scanner: Text scanner, the default is blank to split;
| 123456 |
scanner Usedelimiter (String pattern) //sets the separator mode of this scanner to the pattern constructed from the specified String. scanner (file file) // Scan file Files scanner (InputStream in); scanner sc = new scanner (system.in); boolean hasnextxxx (): xxx nextxxx (): |
- Generally use a character stream with the best cache flow wrapper, improve efficiency, buffer prefix plus the trailing stream name is the corresponding buffer stream
- Sequenceinputstream: Merge stream merges two streams together to become a stream
Java Basic Learning Note "10" print stream, pipeline flow