/** * Class to read a file and place the contents into * a JTextPane from the calling class * * @author David Mitchell, dave@dbmdata.com * @version 1.0 * @see http://www.dbmdata.com * @deprecated uses readLine() from java.io.DataInputStream */ import java.io.*; import javax.swing.*; import javax.swing.event.*; public class FileRead { public FileRead(File file, FileReaderWindow fRead) { if (file != null) { try { String lines = null; // open the file FileInputStream f = new FileInputStream(file); // Convert our input stream into a DataInputStream DataInputStream in = new DataInputStream(f); // continue to read lines while there is something left to read while(in.available() != 0) { lines += in.readLine(); } in.close(); // add the contents to the textpane! fRead.textPane.setText(lines); } catch(Exception e) { JOptionPane.showMessageDialog(null, e, "alert", JOptionPane.ERROR_MESSAGE); } } } }