Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

method does not write

Thread view: 
Loek Raemakers - 07 Nov 2007 18:23 GMT
Ls,
My application runs on a Novell intra-network (NDS6).
The application consists of  different frames.
My problem is: one method does not write to a file.
On a stand alone (Windows  '98 and XP) this problem does not occur.
The method  is:
public void Herschrijver()
{
String text = "blablabla";
String dir = System.getProperty("user.dir");
String sep = System.getProperty("file.separator");
String bestand = "Opgaven.txt";
String pad = dir + sep + bestand;
try
{
Writer fw = new FileWriter(pad);
w.write(text);
fw.close();
}
catch(Exception e)
{
//ta.setText("Fout bij opslaan" + "\n" + e.toString());
    }
//ta.setText("Goed opgeslagen");
}
Using the next line of  code in the above method works fine;
Writer fw = new FileWriter(pad,true);// append text, is not what I want.
Using 'false' instead  of  'true' does not write.
On the file 'Opgaven.txt' I have the netware rights indicated by:
R-W-E-C-M-F.
I do not catch an exception, I get the message in textarea (ta): Goed opgeslagen
Does my (bad) java code cause the problem?
Is it a question of  netware rights or inheritance of these rights by different
frames?
Thanks for any help.
Loek eR
Andrew Thompson - 08 Nov 2007 00:43 GMT
...
> My problem is: one method does not write to a file.
...
> I do not catch an exception, I get the message in textarea (ta): Goed opgeslagen
> Does my (bad) java code cause the problem?

You might try a flush() before the stream close().

If that does not work, I suggest you prepare an SSCCE.

Andrew T.
Esmond Pitt - 08 Nov 2007 02:06 GMT
> You might try a flush() before the stream close().

The close() method is inherited and specified there to call flush() so
that won't help.

@OP: the code you posted suppresses exception traces. I suspect an
exception is being thrown and ignored.
Andrew Thompson - 08 Nov 2007 05:21 GMT
...
>@OP: the code you posted suppresses exception traces. ..

NO IT DOES NOT.. oh wait - yes it does.  I thought I'd
ruled that out.  (grumbles) Damn snippets.

>..I suspect an
>exception is being thrown and ignored.

Tut, tut.  Never swallow stacktraces.  They are your
friend* when you have no others.

*  But they are not good drinking buddies, and don't ever
loan them your car..

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Loek Raemakers - 08 Nov 2007 21:26 GMT
Thanks for the reactions,

I will stop suppressing exceptions.
Next week I have the opportunity to see the result.

Loek eR


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.