[2453] in java-interest
Belgian read-file problem
daemon@ATHENA.MIT.EDU (Tim Moons)
Mon Oct 2 22:39:24 1995
Date: Mon, 2 Oct 1995 17:50:14 +0100
To: java-interest@java.Eng.Sun.COM
From: tim@nic.INbe.net (Tim Moons)
Hello everybody,
I`m working in WIN95.
I have a problem!!
I try to read with an applet the contents from a textfile.
When I try to open the InputStream, he trows an Exception.
What do I wrong??
My program is the following :
(INPUT.txt is just some text in a textfile in the classes-directory)
import browser.Applet;
import awt.*;
import java.util.Date;
import java.io.*;
import java.lang.String;
class reading extends Applet implements DialogHandler {
Font dialogFont;
static String text="text at the beginning";
static int teller=1;
public void init() {
resize(500,150);
dialogFont= getFont("DialogInput", Font.PLAIN, 12);
}
public void paint(Graphics g) {
String hulp, Suur, Smin;
Date date=new Date();
int uur,min;
uur=date.getHours(); min=date.getMinutes();
if (uur-1<10) {
Suur="0" + String.valueOf(uur-1);
}
else {
Suur=String.valueOf(uur-1);
}
if (min<10) {
Smin="0" + String.valueOf(min);
}
else {
Smin=String.valueOf(min);
}
g.setForeground(Color.white);
g.paint3DRect(0,0,500,150,true,false);
g.setForeground(Color.black);
g.drawString(text,5,15);
g.drawString(Suur + ":" + Smin,240,50);
if (teller==1) {
teller++;
write();
}
}
public void write() {
String filename="INPUT.txt";
File file;
FileInputStream Finstream;
try {
file=new File(filename);
Finstream=new FileInputStream(file);
} catch (Exception e) {
text="There is something wrong !!!!!!!";
if (teller==1) {
repaint();
}
return;
}
DataInputStream dis=new DataInputStream(Finstream);
text=dis.readLine();
while(text.length() != -1) {
repaint();
text=dis.readLine();
}
Finstream.close();
}
}
Thanks in advance .......
Tim Moons
Email : tim@innet.be
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com