| new DataInputStream ( inputstream ) | ใช้สร้าง Object DataInputStream |
|---|---|
| close() | ใช้ปิดการใช้งาน stream |
| available() | ใช้คืนค่า ขนาดของ stream ( หน่วย byte ) |
| skip() | ใช้ ข้ามข้อมูล ตามจำนวนที่กำหนด ใน stream |
| read() | ใช้อ่านค่า ascii ของข้อมูลใน stream ณ ตำแหน่ง pointer ปัจจุบัน |
method:new DataInputStream ( inputstream );
return type:DataInputStream
content:ใช้สร้าง Object DataInputStream
example:FileInputStream file_inputstream = new FileInputStream ( "C:/bamboo.txt" ); DataInputStream data_inputstream = new DataInputStream ( file_inputstream );
method:close ();
return type:void
content:ใช้ปิดการใช้งาน stream
example:FileInputStream file_inputstream = new FileInputStream ( "C:/bamboo.txt" ); DataInputStream data_inputstream = new DataInputStream ( file_inputstream ); data_inputstream.close ();
method:available ();
return type:int
content:ใช้คืนค่า ขนาดของ stream ( หน่วย byte )
example:FileInputStream file_inputstream = new FileInputStream ( "C:/bamboo.txt" ); DataInputStream data_inputstream = new DataInputStream ( file_inputstream ); int size_stream = data_inputstream.available ();
method:skip ( long_size );
return type:long
content:ใช้ ข้ามข้อมูล ตามจำนวนที่กำหนด ใน stream
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_inputstream = new FileInputStream ( filename ); DataInputStream data_inputstream = new DataInputStream ( file_inputstream ); data_inputstream.skip ( 100 );
method:read ();
return type:int
content:ใช้อ่านค่า ascii ของข้อมูลใน stream ณ ตำแหน่ง pointer ปัจจุบัน โดยจะคืนค่า -1 กลับมาหากไม่มีข้อมูลอยู่แล้ว
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_inputstream = new FileInputStream ( filename ); DataInputStream data_inputstream = new DataInputStream ( file_inputstream ); int buffer = data_inputstream.read ();