Java Basic Learning Note "10" print stream, pipeline flow

Source: Internet
Author: User

  1. 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
  2. Operation Flow, no matter what the flow, the safest way is to close it all at last
  3. Memory streams: Bytearrayinputstream, Bytearrayoutputstream, CharArrayReader, Chararraywriter:
  4. 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
  5. 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);
  6. 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)
  7. Properties:
    12 voidload(InputStream in);//去加载资源,以流的方式传输  String getProperty(String key, String defaltValue)://根据key找value,其实就是Map里的get(Object key);
  8. 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 ():
  9. 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
  10. Sequenceinputstream: Merge stream merges two streams together to become a stream



Java Basic Learning Note "10" print stream, pipeline flow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.