Convert byte streams to byte streams, and convert byte streams to characters.

Source: Internet
Author: User

Convert byte streams to byte streams, and convert byte streams to characters.

The readLine method is the method in the BufferedReader class of the bytes stream.

The keyboard read method is the byte stream InputStream method.

Can I change byte stream to the bytes stream and use the readLine method of the SWAp stream buffer?

 

InpuStream in = System. in;

// Convert a byte stream object to a byte stream

InputStreamReader isr = new InputStreamReader (in );

// Use the shard stream buffer to improve efficiency

BufferedReader bufr = new BufferedReader (isr );

String line = null;

While (line = bufr. readLine ())! = Null ){

 

if(“over”.equals(line))

        break;

 

sysout(line.toUpperCase());

}

Bufr. close ();


What is the conversion between byte stream and byte stream in IO stream? Explanation

Byte streams can be encapsulated into bytes streams.
01. // create a byte stream
02. FileOutputStream fos = new FileOutputStream (new File ("F: \ testSource \ newFile2.txt "));
03. // convert the output stream of the stream packaging (Change byte stream to the bytes Stream)
04. OutputStreamWriter osw = new OutputStreamWriter (fos );
05. // write characters to the stream
06. osw. write ("this ");
07. osw. write ("is ");
08. osw. write ("OutputStreamWriter ");
09. // fl the stream into the file
10. osw. flush ();
11. // close the stream
12. fos. close ();

The primary stream cannot be converted into word-based throttling.
Reference: blog.csdn.net/..707762

In java, how does one switch the sub-byte stream to the bytes stream?

InputStreamReader input =
New InputStreamReader (
New FileInputStream ("byte stream "),
Charset. forName ("UTF-8 "));

Related Article

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.