Java Java Discussion: "Programming assistance?"

Java Discussion: “Programming assistance?”

Welcome. Click here to access the
new home of Gamelan’s
discussions
on Java.

From the Gamelan Forum…


Programming assistance

Matt Andrew – 09:26am Dec 6, 2001 EDT

I am trying to write to a file. When I build it I get an error that says
“DataOutputStream is not an interface name”. Here is some of my source code:

import com.ms.wfc.app.*;

import com.ms.wfc.core.*;

import com.ms.wfc.ui.*;

import com.ms.wfc.html.*;

import java.awt.event.*;

import java.io.*;

public class newRecords extends Form implements DataOutputStream

{

main record = new main();

DataOutputStream ostream;

public newRecords() throws IOException

{

super();

try

{

ostream = new DataOutputStream(new FileOutputStream());

}

catch(IOException e)

{

System.err.println(“File not opened”);

System.exit(1);

}

button1.addOnClick(ostream.writeUTF(record.date));

button1.addOnClick(ostream.writeUTF(record.checkNum));

button1.addOnClick(ostream.writeUTF(record.description));

button1.addOnClick(ostream.writeUTF(record.debit));

button1.addOnClick(ostream.writeUTF(record.payment));

button1.addOnClick(ostream.writeUTF(record.fees));

// Required for Visual J++ Form Designer support

initForm();

// TODO: Add any constructor code after initForm call

}

I would love an suggestions anyone might have. I have been working on this
for over a week. Thanks.


Norm R – 09:48am Dec 6, 2001 EDT (1.)

It would help when you post error messages, if you would copy and paste the
FULL text of the message. That usually includes the line number of the error
and shows the line itself where the error was. That can save a lot of
guessing!!!

The error is that your class tries to “implement” a class and not an interface.
You can only implement interfaces, NOT classes. To get your code to compile,
remove the “implements” clause from the class statement.


ghazala – 08:20am Dec 7, 2001 EDT (2.)

I have to write a prog where I have to read a file … This can be easily
done using file reader but the problem is this file has new lines every now
and then and I want my programme to read the file every time a new line is
added … Also since this file is very long, I don’t want my programme to read
from the begning every time a new line is added. It should read only the new
line… Pls help… I need quick reply


Norm R – 09:07am Dec 7, 2001 EDT (3.)

If you want to read the file at any location, not just sequentially from
the beginning, use the RandomAccessFile class. It allows you to position to
any byte in the file with the seek() method. The problem is knowing where
individual records begin and end. One way to solve that problem is to have
all the records be of a fixed size.


ping203 – 06:21pm Dec 13, 2001 EDT (4.)

the jdk version i have is 1.3.1 and there are two DataOutputStream classes,
one belongs to java.io which is a class, and one belongs to org.omg.CORBA
which is an interface

so, if your intention is org.omg.CORBA, do implements org.omg.CORBA


crizzorange – 10:22am Dec 17, 2001 EDT (5.)

hi,

… implements DataOutputStream

can’t work as DataOutputStream is not an interface so it can’t be
implemented ;-))

HTH,

Christian


anil kar – 06:11am Dec 29, 2001 EDT (6.)

I’ve to give the full path while accessing the file using the following code.
Is there any alternative where i can provide the relative path and still
get the desired result?

BufferedReader in = new BufferedReader (new FileReader
(“/apps/secDBadmin/classes/database.cfg”));

I’m accessing the file database.cfg from a class which is inside the same
folder (/apps/secDBadmin/classes).

We hope you’ll participate in the give and take of information with your
peers that has been a hallmark of our site since the early days of Java technology.

If you’ve got a problem, here’s the perfect place to ask others for help
solving it. If you’ve got advice, here’s the perfect place to help build a
community of like-minded Java specialists. Enjoy!

The Dalang

Latest Posts

Related Stories