Java Training: Input/Output Example
 
Filter Streams Example
/**
 * This source example shows how to use Filter Streams
 * for writing integers into a file
 * @@author Jeff Zhuk
 */
	
	// create a file output stream 
	FileOutputStream file = new FileOutputStream("int.array");
	// link it to a data output stream
	DataOutputStream data = new DataOutputStream(file);
	// writing an array of integers scores[] into the file
	for(int i = 0; i < scores.length; i++)
	{
		data.writeInt(scores[i]);
	}
	// close the data stream, then
	// close the file stream, the "topmost" order is important
	data.close();
	file.close();