// NumbersToFile.java Copyright (c) 2005 Kari Laitinen // http://www.naturalprogramming.com // 2003-12-10 File created. // 2005-05-08 Last modification. import java.io.* ; class NumbersToFile { public static void main( String[] not_in_use ) { try { FileOutputStream file_output_stream = new FileOutputStream( "NumbersToFile_output.data" ) ; DataOutputStream file_to_write = new DataOutputStream( file_output_stream ) ; int integer_to_file = 0x22 ; while ( integer_to_file < 0x77 ) { file_to_write.writeInt( integer_to_file ) ; integer_to_file = integer_to_file + 0x11 ; } file_to_write.writeShort( (short) 0x1234 ) ; file_to_write.writeDouble( 1.2345 ) ; file_to_write.writeBoolean( true ) ; file_to_write.writeBoolean( false ) ; file_to_write.writeUTF( "aaAAbbBB" ) ; byte[] bytes_to_file = { 0x4B, 0x61, 0x72, 0x69 } ; file_to_write.write( bytes_to_file, 0, 4 ) ; file_to_write.close() ; } catch ( Exception caught_exception ) { System.out.print( "\n File error. Cannot write to file." ) ; } } }