CN Finishing IO Basics

Source: Internet
Author: User


/*file f=new File ();
*
* File F=new file ("E:\\a.txt");
F.exists ();//judgment exists not
F.mkdirs ();//Create
F.getpath ();//Get relative path
F.delete ()//delete
F.listfiles (filter);//File array
F.list ();//array of strings for all subdirectories under the file

--------------------------------------------------------------------------------------
Flow
*
*
*
*
*
*
* Create file: Create a time to judge, if not saved directly to create (destination source write)
* File F=new file ("D:\\io");
if (f.exists ()) {
F.mkdirs ();
}
*
*
*
*
* Byte stream:
* FileInputStream f=new FileInputStream ("E:\\a.txt");
FileOutputStream fo=new FileOutputStream ("e:\\");
* Byte buffers:
*
Bufferedinputstream in=new Bufferedinputstream (in parentheses);
Bufferedoutputstream out=new Bufferedoutputstream (in parentheses);

*
*
* Character Stream:
* FileWriter fw=new FileWriter ("D;\\a.txt");
FileReader fr=new FileReader ("D;\\a.txt");
*
* Character buffers
* BufferedReader buff=new BufferedReader (in parentheses);
BufferedWriter buffe=new BufferedWriter ();

Custom buffers:
Buffer of Byte[]b=new byte[1024*1024];//1m
*
* Byte and Character conversions:
* InputStreamReader reader=new InputStreamReader ();//convert byte read stream to character read flow
*
OutputStreamWriter writ =new outputstreamwriter ()//convert byte read stream to character read flow
* Keyboard read:
* Keyboard input is the character, system.in. Need to be placed in the character conversion stream
* Same System.out Also
*
Read and Write
* Idea: Read the source file first. Write it when you're done reading
* Read and write on the side
* Split file ideas:
* Main Yes by custom buffer size to cut files
* (******) is mainly to write out the flow definition to while ()
*
*
FileInputStream file=new FileInputStream (New file ("E:\\id3.mp3"));//Read source
Byte[]b=new byte[1024*1024];//Custom Buffer size
int len=0;
File F=new file ("D:\\MP7");//Create Folder
if (f.exists ()) {
F.mkdirs ();
}
int count=1;
FileOutputStream Out=null;
while ((Len=file.read (b))!=-1) {
Out=new FileOutputStream (New File (F, (count++) + ". mp3"));//cycle produces one flow at a time
Out.write (B,0,len);

}
Out.close ();//Mathematic
File.close ();

*------------------Important------------------------------------------of *********--
* This allows you to read or write, and then write the configuration file when splitting:
* Used to set
*
* Properties PPS = new properties ();
*
* is often related to writing configuration files,
* Directly load into the output stream to write out
* Pps.setproperty (key, value), key-value pair form exists.
*
* Pps.load (instream);//download it from the stream
* Pps.store (output stream, first name);//Load to Collection
*
*
*

2016/05/13 Day Finishing:

Learning is not a task! Like IS dry!!! Do not like also to do!!


* */

CN finishing IO Fundamentals

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.