Goob
January 31st, 2000, 10:22 AM
I'm trying to read the contents of a file into the jtextarea using Jbuilder3 here is my code.
void jButton1_actionPerformed(ActionEvent e)
{
FileDialog d = new FileDialog(this, "Text Editor");
d.setFile ("*.txt");
d.setDirectory (".");
d.show();
val = d.getDirectory() + d.getFile();
try{
FileInputStream inStream = new FileInputStream(val);
while (!eof) {
int c = inStream.read();
if(c == -1) eof = true;
else{
System.out.print ((char)c);
jTextArea1.setText ((char)c); //trying to read here
}
}
}
catch(IOException i)
{
}
void jButton1_actionPerformed(ActionEvent e)
{
FileDialog d = new FileDialog(this, "Text Editor");
d.setFile ("*.txt");
d.setDirectory (".");
d.show();
val = d.getDirectory() + d.getFile();
try{
FileInputStream inStream = new FileInputStream(val);
while (!eof) {
int c = inStream.read();
if(c == -1) eof = true;
else{
System.out.print ((char)c);
jTextArea1.setText ((char)c); //trying to read here
}
}
}
catch(IOException i)
{
}