): Pipedreader, PipedWriter, PipedInputStream, PipedOutputStream
3.File file Stream
Read and write to files: FileReader, FileWriter, FileInputStream, FileOutputStream
4. Objectserialization
Object input, Output: ObjectInputStream, ObjectOutputStream
5.DataConversion Data Flow
Read and write by basic data type (processed data is the basic type of Java (such as Boolean, Byte, Integer, and floating-point numbe
FileInputStream, each time it reads 512 bytes from the source program file Openfile.java, stores it in buffer buffers, and then constructs the string new string with the value in buffer ( Buffer) is displayed on the screen. The program is as follows (this example is placed in the package Biz.1cn.stream, in addition, please create a TestFile.txt file in the root directory for normal operation):1 PackageBiz.1cn.stream; 2 ImportJava.io.FileInputStream; 3 Importjava.io.IOException; 4
outputstream to writer Transformation Bridge, its subclass filewriter is actually a concrete class to implement this function; * */public class IO {public static void Main (string[] args) throws IOException {//character stream string path = "Data/data"; BufferedReader br = new BufferedReader (new InputStreamReader (New FileInputStream (path), "Utf-8")); String line = "", while (line = Br.readline ())! = nu
JAVA 56th-IO stream (10) Object serialization and deserialization RandomAccessFile, io serialization
Operation object
ObjectInputStream and ObjectOutputStream
The operated object must implement Serializable (Mark Interface)
ObjectOutputStream writes the basic data types and graphics of Java objects to OutputStream. You can use ObjectInputStream to read (refactor
The Java.io.File class is used to represent files (directories)The file class is used only for information (name, size, etc.) that represent files (directories) and cannot be used for access to file contentRandomaccessfile Java provides access to the contents of a file that can be read or written.Randomaccessfile supports random access to files and can access any location in the file(1) Java file modelThe f
The difference between a character stream and a byte streamTake a look at an example of the previous article:1 public static void main (string[] args) throws Exception 2 {3 file File = new file ("D:/writer.txt"); 4 writer ou t = new FileWriter (file); 5 //declares a String type Object 6 string str = "Hello world!!!"; 7 out.write (str); 8 out.close (); 9 // Read file operation
stream.Conversion flow: Inputstreamreader/outputstreamwriter, converting bytes into charactersBuffered buffer stream:: Bufferedinputstream,bufferedoutputstream,bufferedreader,bufferedwriter, is a processing stream with buffers, bufferingThe main purpose of the district is to avoid dealing with the hard disk every time and improve the efficiency of data access.Object flow: Objectinputstream,objectoutputstre
I. Input and Output1. Stream represents any data source capable of producing data or any receiving source capable of receiving data. In Java I/O, all streams (including input and out stream) have two types:1.1 byte-oriented streamA byte-oriented stream that reads or writes information to a
, "utf-8"); Osw.write ("Hello! ");//Do not write flush cannot flush buffered write file, close Close file also has this functionOsw.write (' Medium ');//write single characterOsw.write ("First meeting, please take more care", 2, 3);//write a part of a string; start with the second character, write three altogether
char[] ch = {' present ', ' Day ', ' Down ', ' rain '}; Osw.write (CH); //write array osw.write (CH, 2, 2); //Starting from the
Java input and output can be divided into two categories, streaming and non-streaming operations, streaming operations mainly concerned with the reading and writing of the contents of the file, non-streaming operations are mainly used for file management on disk. The following first learns streaming data operations.FlowSimilar to C + +, the concept of flow is also provided in Java to handle input and output
Java Base IO Stream (i) byte stream IO flow system is too large, involving a variety of flow objects, I think it is necessary to summarize.What is an IO stream, IO represents input, Output, and the flow is an abstraction of the data transfer from the original source to the target medium. Typical data sources and targe
Flow :Concept: The operation of a file in Java is done in a streaming fashion. A stream is an ordered set of data sequences in Java memory. Java reads the data from the source (file, memory, keyboard, network) into memory, forms a stream, and then writes those streams to ano
): Writes out one byte array at a time* Available () Gets the number of bytes read from the file* Disadvantages: There may be memory overflowFileInputStream fis = new FileInputStream ("to Youth. mp3");FileOutputStream fos = new FileOutputStream ("Copy.mp3");byte[] arr = new byte[fis.available ()];//make a byte array based on file sizeFis.read (arr);//Read all the bytes on the file into the arrayFos.write (arr);//Writes all the bytes in the array once to the fileFis.close ();Fos.close ();# # #IO流
(upper + ""); data = baiS. read ();} baiS. close ();}}
The running result is as follows:
2. ByteArrayOutputStream class
ByteArrayOutputStream writes data to the byte array in the memory. Its data is a byte array. ByteArrayOutputStream adapter design mode, which converts the byte array type to the output stream type so that the program can write the byte array.
The ByteArrayOutputStream class is constructed as follows:
ByteArrayOutputStream (): Creat
Java mysql large data volume batch insertion and stream read AnalysisThis week, we will help the customer solve some problems and solutions regarding the use of the mysql driver for report generation operations. Since the report generation logic reads a large amount of data from the database and processes it in the memory, a large amount of summary data is generated and then written to the database. The bas
The difference between a character stream and a byte streamTake a look at an example of the previous article:1 Public Static voidMain (string[] args)throwsException2 {3File File =NewFile ("D:/writer.txt");4Writer out =NewFileWriter (file);5 //declares a String type object6String str = "Hello World!!!";7 out.write (str);8 out.close ();9 Ten //Read File Operation OneReader in =Newfilereader (
only explicitly load the driver files that were before JDBC 4.0.Listing 8. Lists the JDBC drivers on the local machineenumerationRowIdPeople familiar with large DBMS such as DB2 and Oracle must not be unfamiliar with the concept of ROWID: It is a "hidden" column in a data table, a unique identifier for each row, indicating the physical or logical location of the
intercept eight bits). As a result, the message is that the Java byte stream reads byte into int and then goes back to byte to save it. Why not?After some thought, I had an initial answer: When reading a byte data with the input stream, there are sometimes 8 consecutive 1 cases, which represents-1 within the computer,
mark as placeholder
4
5 String Sql = "INSERT into tableName values (?,?)"
6
7 PreparedStatement pre = Conn.preparedstatement (SQL);
8
9 Pre.setint (1,99);
Ten
pre.setstring (2, "ASD");
Int count = Pre.executeupdate (); 3. Transaction processing Transaction: is a complete unit of operation consisting of related SQL operations, which is used as a whole to either do it all or not Four properties of a transaction: Atomicity: Either to do it
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.