經常使用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
|
|
Constructor Summary
|
|
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. |
|
|
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
|
|
void
|
int
|
read
() Reads a single character. |
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
|
|
void
|
close
() Closes the stream, flushing it first. |
void
|
flush
() Flushes the stream. |
Constructor Summary
|
|
Constructor Summary
|
|
OutputStreamWriter
(
OutputStream
out) Creates an OutputStreamWriter that uses the default character encoding. |