Memory Stream (Array stream):The data is temporarily present in the array and will be retrieved from the array later.1. Byte memory stream: Bytearrayinputstream/bytearrayoutputstream2. Character Memory stream: Chararrayinputstream/chararrayoutputstream3. String stream: Strin
-matched. 4. transient keyword transientwhen an object of a class needs to be serialized, some attributes do not need to be serialized, and attributes that do not need to be serialized can be decorated with the keyword transient . This property is not serialized when serialized, as long as the transient is modified. Static adornments are not serialized at the same time, because serialization is the persistent storage of object data, while static data belonging to the class load is not serializ
;//fix him a pinch . - the PrivateString name;Bayi transient intAge//cannot be serialized after use of transient the StaticString country= "cn";//Static also cannot be serialized thePerson (String name,intage,string Country) { - This. name=name; - This. age=Age ; the This. country=Country; the } the PublicString toString () { the returnname+ "=" +age+ "=" +Country; - } the}Dark Horse programmer--
One of the key areas of Java learning: OutputStream byte output stream usageFileOutputStream: Sub-class, write the channel of the dataSteps:1. get the target file2. Create a channel (if there is no target file, it will be created automatically)3. writing data write ()4. Releasing ResourcesAttention:(1) if the target file does not exist, it will create a target file by itself(2) if the target file exists, fi
Stream objects created in IO Stream operations Why must I close?Here we need to note that when we create an IO stream object in the program, and the system also creates a thing called the stream, in this case, the computer memory actually produces two things, one is the Java
Use of data flow (stream)
1) Stream's acquisition
① through the collection collection get
1
list2
stream
② is obtained by array
1
String[] Array = {"Are", "You", "OK"};2
stream3
4
Handling of primitive type arrays5
Int[] array = {1,2,3,4,5};6
stream
③ by value (as far as possible using the above 2 ways to get, this way there are defects)
1
Differences between byte stream and byte stream storage in Java, using several common types of data to compare the differences between byte stream and byte streamInt A = 5;Boolean B = true;Char c = 'G ';String d = "hello ";Print the data of the above types to the file using the ghost stream:Printwriter dos = new printw
/* characters written to buffer stream buffers appear in order to improve the operational efficiency of the stream. So before you create a buffer, you must have an existing stream object. Writer corresponds to Bufferedwriterreader bufferedreader the buffer provides a line break method, NewLine (); */import Java.io.*;class Bufferedwriterdemo {public static void ma
Java IO stream: Random file read/write, javaio stream
The Java. io package provides the RandomAccessFile class for creating and accessing random files. Using this class, you can jump to any position of the file to read and write data. The program can insert data into a random file without damaging other data of the fil
;//declaring a print stream object//If you are using Fileouputstream instantiation, it means that all output is to the filePS =NewPrintStream (New FileOutputStream(NewFile ("D:" + File.separator + "Test.txt"))) ; String name= "Li Xinghua";//Defining Strings intAge = 30;//defining integers floatScore = 990.356f;//Defining decimals CharSex = ' M ';//Defining charactersPs.printf ("Name:%s; age:%d; score:%f; Gender:%c" , name,age,scor
@1: Byte stream:Java.io.InputStream:Public abstract class InputStreamThis abstract class was the superclass of all classes representing an input stream of bytes.Java.io.OutputStream:Public abstract class OutputStreamThis abstract class was the superclass of all classes representing an output stream of bytes.InputStream is the ancestor of all byte input streams, and OutputStream is the ancestor of all byte o
1. Bufferedinputstream reading dataBufferedinputstream construction method, as follows:
Construction Method Summary
BufferedInputStream(InputStreamin)Create one BufferedInputStream and save its arguments, that is, the input stream for in future use.
BufferedInputStream(InputStreamin, intsize)creates a specified buffer size BufferedInputStream and saves its arguments, that is, the input
();
File File = new file ("C:\\users\\joke\\desktop\\demo1.java");
FileInputStream FileInputStream = new FileInputStream (file);
The buffer is generally set to a multiple of 1024. Theoretically set the larger the buffer, the higher the Reading efficiency
byte[] bt = new byte[1024];
int count = 0;
Read returns-1, the proof has been traversed while
((count = Fileinputstream.read (BT))!=-1) {
//string display (start traversing the count length from the
Package Copyfile;import java.io.*;p ublic class Copy {public static void main (string[] args) throws IOException {CopyFile ( "D:/new/a.txt", "D:/new/b.txt", true);//oldpath,newpath, does not overwrite the preceding}public static void CopyFile (String oldpth,string Newpath,boolean add) throws ioexception{fileinputstream in = null; FileOutputStream fs = null;try {///instantiate the file and determine if the file is present in document Oldfile=new file (oldpth); if (Oldfile.exists ()) {//Initialize
Reader,inputstream is used to read the contents of a resource, which can be a file or a networkFirst, there is a TXT file, the contents of the file are as followsFile F = new files ("path"); FileInputStream fis = new FileInputStream (f);//create an input stream, read the contents of F into the program to//SYSTEM.OUT.PRINTLN (Fis.read ()); byte[] B = new byte[1024];//defines an array that holds the read class tolerance int hasread = 0;//used to record
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.