常用Java IO Classes 关系图
|
||||
Byte
|
InputStream/ OutputStream
|
Node
Byte Stream
|
FileInputstream/ FileOutputStream
|
|
PipeInputStream/
PipeOutputStream
|
|
|||
…
|
|
|||
Processing Byte Stream
|
FilterInputStream/
FilterOutputStream
|
BufferInputStream/
BufferOutputStream
|
||
DataInputStream/
DataOutputStream
|
||||
PrintStream
|
|
|||
…
|
|
|||
Byte 与 Char 通过 InputstreamReader 和 OutputStreamWriter 来转换
|
||||
Char
|
Reader/Writer
|
Node
Char Stream
|
FileReader/FileWriter
|
|
PipeReader/PipeWriter
|
|
|||
…
|
|
|||
Processing Char Stream
|
|
BufferReader/
BufferWriter
|
||
PrintWriter
|
|
|||
…
|
|
abstract int
(可对应Char)
|
read ()
Reads the next byte of data from the input stream |
int
|
read (byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b. |
void
|
close ()
Closes this input stream and releases any system resources associated with the stream. (Stream 用完之后要注意关闭!) |
abstract void
|
write (int b)
Writes the specified byte to this output stream. |
void
|
write (byte[] b)
Writes b.length bytes from the specified byte array to this output stream. |
void
|
close ()
Closes this output stream and releases any system resources associated with this stream. |
void
|
flush ()
Flushes this output stream and forces any buffered output bytes to be written out. (不必等buffer满了再写出,强行把所有的东西都写出来) |
boolean
|
readBoolean ()
|
byte
|
readByte ()
|
char
|
readChar ()
|
double
|
readDouble ()
|
float
|
readFloat ()
|
int
|
readInt ()
|
void
|
writeBoolean (boolean v)
Writes a boolean to the underlying output stream as a 1-byte value. |
void
|
writeByte (int v)
Writes out a byte to the underlying output stream as a 1-byte value. |
void
|
writeDouble (double v)
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first. |
void
|
writeFloat (float v)
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first. |
void
|
writeInt (int v)
Writes an int to the underlying output stream as four bytes, high byte first. |
Constructor Summary
|
|
FileReader ( File file)
Creates a new FileReader, given the File to read from. |
|
FileReader ( String fileName)
Creates a new FileReader, given the name of the file to read from. |
Constructor Summary
|
|
FileWriter ( File file)
Constructs a FileWriter object given a File object. |
|
FileWriter ( File file, boolean append)
Constructs a FileWriter object given a File object. |
|
FileWriter ( String fileName)
Constructs a FileWriter object given a file name. |
|
FileWriter ( String fileName, boolean append)
Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. |
Constructor Summary
|
|
PrintWriter ( File file)
Creates a new PrintWriter, without automatic line flushing, with the specified file. |
|
PrintWriter ( OutputStream out)
Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream. |
|
PrintWriter ( Writer out)
Creates a new PrintWriter, without automatic line flushing. |
|
void
|
println (boolean x)
Prints a boolean value and then terminates the line. |
void
|
println (char x)
Prints a character and then terminates the line. |
void
|
println (double x)
Prints a double-precision floating-point number and then terminates the line. |
void
|
println (float x)
Prints a floating-point number and then terminates the line. |
void
|
println (long x)
Prints a long integer and then terminates the line. |
void
|
println ( Object x)
Prints an Object and then terminates the line. |
void
|
println ( String x)
Prints a String and then terminates the line. |
int
|
read ()
Reads a single character. |
String
|
readLine ()
Reads a line of text. |
void
|
close ()
Closes the stream and releases any system resources associated with it. |
void
|
write (char[] cbuf, int off, int len)
Writes a portion of an array of characters. |
void
|
write ( String s, int off, int len)
Writes a portion of a String. |
void
|
close ()
Closes the stream, flushing it first. |
void
|
flush ()
Flushes the stream. |
Constructor Summary
|
|
InputStreamReader ( InputStream in)
Creates an InputStreamReader that uses the default charset. |
Constructor Summary
|
|
OutputStreamWriter ( OutputStream out)
Creates an OutputStreamWriter that uses the default character encoding. |