// simple example of building a file sequentially
// putting 100 strings (same value, same length) into the file
// note when using files java requires that you provide code
// to handle error exception that could occur
// this is what the try and catch is all about
//-----------------------------------------------------------
import java.awt.*;
import java.net.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class Application1
{
public Application1()
{
String testname=new String("computer 123456789");
try
{
FileOutputStream fileout = new
leOutputStream("fileone");
DataOutputStream out = new
DataOutputStream(fileout);
for (int n=1;n<100;n++)
out.writeBytes(testname);
fileout.close();
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null,"io error","handle
error",JOptionPane.NO_OPTION);
}
}
public static void main(String[] args)
{
Application1 app = new
Application1();
System.exit(0);
}
}
|