| new FileInputStream ( object_file ) | ใช้สร้าง Object FileInputStream |
|---|---|
| new FileInputStream ( filename ) | ใช้สร้าง Object FileInputStream |
| close() | ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ |
| finalize() | ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ |
| available() | ใช้คืนค่า ขนาด ของ stream มีหน่วยเป็น byte |
| skip() | ใช้ ข้ามข้อมูล ตามจำนวนที่กำหนด ใน stream |
| read() | ใช้อ่านค่า ascii ของข้อมูลใน stream ณ ตำแหน่ง pointer ปัจจุบัน |
method:new FileInputStream ( object_file );
return type:FileInputStream
content:ใช้สร้าง Object FileInputStream
example:File file = new File ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( file );
method:new FileInputStream ( filename );
return type:FileInputStream
content:ใช้สร้าง Object FileInputStream
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename );
method:close ();
return type:void
content:ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename ); file_input_stream.close ();
method:finalize ();
return type:void
content:ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename ); file_input_stream.finalize ();
method:available ();
return type:int
content:ใช้คืนค่า ขนาด ของ stream มีหน่วยเป็น byte
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename ); int size_stream = file_input_stream.available ();
method:skip ( long_size );
return type:longใช้ ข้ามข้อมูล ตามจำนวนที่กำหนด ใน stream
content:
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename ); file_input_stream.skip ( 100 );
method:read ();
return type:int
content:ใช้อ่านค่า ascii ของข้อมูลใน stream ณ ตำแหน่ง pointer ปัจจุบัน โดยจะคืนค่า -1 กลับมาหากไม่มีข้อมูลอยู่แล้ว
example:String filename = new String ( "C:/bamboo.txt" ); FileInputStream file_input_stream = new FileInputStream ( filename ); String filename_new = new String ( "C:/labcode.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( filename_new ); int buffer = 0; while ( ( buffer = file_input_stream.read () ) != -1 ) { file_output_stream.write ( buffer ); }