Tải bản đầy đủ (.pdf) (5 trang)

Lập trình Java cơ bản : Luồng và xử lý file part 2 docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (52.34 KB, 5 trang )

Luồng byte
6
ByteArrayInputStream
FileInputStream
FilterInputStream
ObjectInputStream
PipedInputStream
SequenceInputStream
StringBufferInputStream
BufferedInputStream
LineNumberInputStream
PushbackInputStream
DataInputStream
InputStream
Luồng byte
7
ByteArrayOutputStream
FileOutputStream
FilterOutputStream
ObjectOutputStream
PipedOutputStream
DataOutputStream
BufferedOutputStream
OutputStream
PrintStream
Luồng nhập/xuất byte cơ bản
8
• InputStream và OutputStream là hai
lớp gốccủamọiluồng nhập/xuất byte
(abstract).
Object


InputStream OutputStream
Lớp InputStream
9
• Mộtsố phương thứccủa InputStream
• abstract int read() throws IOException
• Đọc một byte từ luồng.
• Nếu cuối luồng sẽ trả về -1
• int read(byte[] b) throws IOException
• Đọc một dãy byte từ luồng
• void close() throws IOException
• Đóng luồng nhập
• int available() throws IOException
• Trả về số byte có thểđọc tiếp
• long skip(long n) throws IOException
• Bỏ qua n byte
LớpOutputStream
10
• Mộtsố phương thứccủa OutputStream
• abstract void write(int b) throws IOException
• Ghi mộtbyte raluồng
• void write(byte[] b) throws IOException
• Ghi một dãy byte ra luồng
• void close() throws IOException
• Đóng luồng
• void flush() throws IOException
• Dồnxuất luồng

×