fullFwriter.Close();//Close FileWriter object //Read fileFileReader Freader =NewFileReader (file);Char[] CS2 =New Char[ the]; Freader.Read(CS2);//This is not read by the while loop because it knows the length is not greater than 15 for(CharC:CS2) {//Traversal outputSystem. out.Print(c); } freader.Close();Operation Result:i love javaReference1. Java Stream (stream), file, and Io | Beginner's Tuto
Reprint Please specify the Source: Jiq ' s technical BlogIntroductionNIO, or new IO, was introduced in JDK1.4 to improve IO speed. It is important to note that Javanio is not completely non-blocking IO (no-blocking io) because some of these channels (such as FileChannel) can only be run in blocking mode, while other ch
Class-level diagram that describes the input stream and the output Stream.The two important streams that will be discussed below are FileInputStream and fileoutputstream:
FileInputStreamThe stream is used to read data from a file, and its objects can be created with the keyword NEW.There are several construction methods that you can use to create Objects.You can use the file name of a string type to create an input stream object to read the File:New FileInputStream ("c:/
{Selector acceptselector = Selectorprovider.provider (). Openselector (); /*Register the selector on the server socket and set the notification to accept the acceptance method. this tells selector that the socket wants to be placed in the ready table when the Accept operation occurson, therefore, agree that multivariate non-clogging I/O occurs. */Selectionkey Acceptkey = Ssc.register (Acceptselector,Selectionkey.op_accept);int keysadded = 0;The/*select method returns when an operation that has b
ioexception{Selector acceptselector = Selectorprovider.provider (). Openselector (); /*Register the selector on the server socket and set the notification to accept the acceptance method. this tells selector that the socket wants to be placed in the ready table when the Accept operation occurson, therefore, agree that multivariate non-clogging I/O occurs. */Selectionkey Acceptkey = Ssc.register (Acceptselector,Selectionkey.op_accept);int keysadded =
flush difference: After flush refreshes, the stream can continue to be used, and when close is refreshed, the stream is closed. Fw.close (); }}Attention:In fact, Java itself can not write data, but to call the system internal way to complete the writing of data, using system resources, it is important to close the resources.Close () and flush () differences:Flush () After flushing, the stream can continue to be used;When close () is refreshed, the st
1. Object serialization is to save the current state of the object.
2.There are two main ways to save the object status:
1)Object serialization (write the object to a file and deserialize it later, as shown in the following example)
If the stored data is used in JavaProgramObject serialization is used for internal interaction;
2)Write a file (write an object to a text file. Note thatText Files)
If the stored data is used to interact with other non-
in accordance with the written order, or read out is garbledSystem.out.println (Dis.readbyte ()); System.out.println (Dis.readlong ()); System.out.println (Dis.readchar ()); System.out.println (Dis.readutf ()); //5. Close the streamDis.close (); Bis.close (); Fis.close (); System.out.println ("Read the file complete!" "); } Catch(FileNotFoundException e) {e.printstacktrace (); } Catch(IOException
Because the project needs to use Java to develop a background server program, C + + programmers will learn java. Blog content is used to record my learning process. Several network IO models under Unix/linux have been mentioned in previous blogs, but most of them are system calls under Unix/linux.Most of the blog content from the network information and books "Ne
According to UNIX network programming, IO models can be divided into: blocking io, non-blocking io, io multiplexing, signal-driven IO, and asynchronous Io, divided into two classes according to POSIX standards: synchronous
IO stream 05 -- video Study Notes for bixiangdong JAVA basic tutorial, 05 -- bixiangdong
Day20
10 create a java file list11 Properties12 Properties access13 Properties14 Properties exercises15 PrintWriter16 merge streams17. Cut files
10 create a java file list
Exercise:Store the absolute path of a
first look at a few common Encoding Methodpublic class Encodedemo{public static void Main (string[] agrs) throws ioexception{string s= "China abc"; byte[] byte1= S.getbytes (); The default is the project's UTF-8 encoding byte[] byte2=s.getbytes ("GBK");//display the specified encoding mode is gbkbyte[] byte3=s.getbytes ("utf-16be"); for (byte b:byte1) {/** * converts bytes to int in 16 binary display * The default is the project's code, where UTF-8 i
The so-called IO, which is the abbreviation of input and output. In Java, IO involves a relatively large scope, which focuses on reading and writing about file content
Other knowledge points will be placed in subsequent chapters (I think, the article is too long, no one has the patience to turn to the end)
the operation of the contents of the file is mainly div
will be accepted.
Source: System. in)Purpose: To log on to the console (System. out)1/* write the conversion stream and convert the bytes stream to the byte stream */2 import java. io. *; 3 public class TransStreamDemo2 4 {5 public static void main (String [] args) throws IOException 6 {7 // InputStream in = System. in; 8 // InputStreamReader isr = new InputStre
thread can only do one thing, then we can let the server information read and write in a sub-thread, each user by a child thread user information read and send, this thread should have all the information of that user, also called this thread is the interface thread, All interface threads can be accessed indirectly through an interface thread in the server. Key code :Arraylistwhile (true) { try { Socket socket=serversocket.accept (); System.out.println ("There is a client Access server");User
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.