Java Foundation 14th Day Summary

Source: Internet
Author: User

Package com.client0601;


Import Java.nio.charset.Charset;


public class App {


public static void Main (string[] args) {

For (String key:Charset.availableCharsets (). KeySet ()) {

SYSTEM.OUT.PRINTLN (key);

}

System.out.println (Charset.defaultcharset ());


}


}

Buffer byte stream:

Object-->outputstream-->fileteroutputstream-->bufferedoutputstream

Use of decorative mode

Buffered input stream

Object-->inputstream-->fileterinputstream-->bufferedinputstream

Close ()

Frees the system resources associated with it, multiple shutdowns without impact, no error. Close from outside to inside.

byte array output stream: Bytearrayoutputstream

Object-->outputstream-->bytearrayoutputstream

Open up space in memory and store data. Not a buffer stream

Create it directly and use it to



byte array input stream: Bytearrayinputstream

Object-->inputstream-->bytearrayinputstream

Conversion between Intt and byte[].

InputStreamReader Conversion Stream

Object-->reader-->inputstreamreader

InputStreamReader is not a buffer stream

When using, try to use BufferedReader to pack and improve the efficiency.


Package com.client0602;


Import Java.io.BufferedReader;

Import Java.io.FileOutputStream;

Import Java.io.InputStreamReader;

Import Java.io.PrintStream;


public class Standeriodemo {


public static void Main (string[] args) throws Exception {

BufferedReader br=new BufferedReader (New InputStreamReader (system.in));

System.setout (New PrintStream (New FileOutputStream ("E:/e.txt") {

}));

System.out.println ("Hello word");

String line= "";

while ((Line=br.readline ())!=null) {

if (Line.equals ("Exit")) {

System.exit (-1);

}else{

System.out.println (line);


}

}

Br.close ();

}


}

Describes the IO stream. And the function of the flow.

Input output stream character byte stream, buffered and non-buffered streams.

Bridge stream or transform stream.
Modifies the default output method. Pass in a new print object,

The Print object has overloads of a number of constructors.


File

Directory:

Path: The address of the precise Dingzhun file.

File F=new file ("E:/e.txt");

System.out.println (F.exists ());

String Abspath=f.getabsolutepath ();

String Name=f.getname ();

String Cadfad=f.getcanonicalpath ();

String parent=f.getparent ();

Absolute path

System.out.println (". GetAbsolutePath ():" +abspath);

File name, not copy directory

System.out.println ("F.getname ():" +name);

Get the normal path without (. |.)

System.out.println ("F.getcanonicalpath ():" +CADFAD);

Get the destination of the file

System.out.println ("F.getparent ():" +parent);



Java Foundation 14th Day Summary

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.