| new FileOutputStream ( object_file ) | ใช้สร้าง Object FileOutputStream |
|---|---|
| new FileOutputStream ( object_file, is_continue ) | ใช้สร้าง Object FileOutputStream และกำหนดด้วยว่าต้องการให้เขียนข้อมูลต่อจากข้อมูลเดิมหรือไม่ |
| new FileOutputStream ( filename ) | ใช้สร้าง Object FileOutputStream |
| new FileOutputStream ( filename, is_continue ) | ใช้สร้าง Object FileOutputStream และกำหนดด้วยว่าต้องการให้เขียนข้อมูลต่อจากข้อมูลเดิมหรือไม่ |
| close() | ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ |
| finalize() | ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ |
| write() | ใช้เขียนข้อมูล ลงไฟล์ โดยเขียนข้อมูลจากรหัส ascii ที่กำหนด |
| flush() | ใช้ล้างข้อมูลใน stream ( คือล้างข้อมูลในไฟล์ ) และกำหนดให้ buffer ทำงาน ตามลำดับ |
method:new FileOutputStream ( object_file );
return type:FileOutputStream
content:ใช้สร้าง Object FileOutputStream
example:File file = new File ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( file );
method:new FileOutputStream ( object_file, is_continue );
return type:FileOutputStream
content:ใช้สร้าง Object FileOutputStream และกำหนดด้วยว่าต้องการให้เขียนข้อมูลต่อจากข้อมูลเดิมหรือไม่
example:File file = new File ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( file, true );
method:new FileOutputStream ( filename );
return type:FileOutputStream
content:ใช้สร้าง Object FileOutputStream
example:String filename = new String ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( filename );
method:new FileOutputStream ( filename, is_continue );
return type:FileOutputStream
content:ใช้สร้าง Object FileOutputStream และกำหนดด้วยว่าต้องการให้เขียนข้อมูลต่อจากข้อมูลเดิมหรือไม่
example:String filename = new String ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( filename, true );
method:close ();
return type:void
content:ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ
example:String filename = new String ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( filename ); file_output_stream.close ();
method:finalize ();
return type:void
content:ใช้ปิดการใช้งาน stream และคืนค่าทรัพยากรที่ถูกเรียกใช้ทั้งหมดให้กับระบบ
example:String filename = new String ( "C:/bamboo.txt" ); FileOutputStream file_output_stream = new FileOutputStream ( filename ); file_output_stream.finalize ();
method:write ( int_ascii );
return type:void
content:ใช้เขียนข้อมูล ลงไฟล์ โดยเขียนข้อมูลจากรหัส ascii ที่กำหนด
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 ); }
method:flush ();
return type:void
content:ใช้ล้างข้อมูลใน stream ( คือล้างข้อมูลในไฟล์ ) และกำหนดให้ buffer ทำงาน ตามลำดับ ( buffer ทำงาน คือ เขียนข้อมูลลงไฟล์ )
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 ); } file_output_stream.flush ();