applications does not write

L

Loek Raemakers

Application running on a local network does not write.
The application runs on a Novell network (NDS6), one part a so called E_LAN,
for students only, and a A_LAN for administrative purposes. (Windows XP as
system)
Students use it to sign up; the application places them in groups, and on lists
/ waiting lists. The information is written in a .txt file (CSV) . So far this
(reading and writing) works fine.
I want to make changes in the lists. The problem is that I can not write these
changed information to the text-file, the application seems to 'hang.' This
happens only if the administrator wants to save the changed information to the
txt-file on our local network, not on a stand-alone (Windows XP).
The code for both paths, reading and writing is the same, the path + file is
Q:\\Opgaven.txt
Some code, to write to the file:
"
String abspad = fil.getAbsolutePath();
FileWriter fw = new FileWriter(abspad);
infovector = geefVector();
for ( int i = 0; i < infovector.size()-1; i ++ )
{
String elem = infovector.elementAt(i).toString();
uit = uit + elem + "\n";
}
fw.write(uit);
fw.close();
pta.appendText("\n" + "Gegevens goed opgeslagen");
}
catch (Exception ex)
{
String iks = "" + ex.toString();
''
The exception is:
FileNotFoundException: Q:\\Opgaven.txt

I also tried a hard-coded path.
In what direction I have to look for a solution for my problem ?
Is the file open, so writing is impossible?
Is it the 'wrong' writer ?
Why this works on a stand alone and not in a intra network?
Any help would be great.
 
A

Andrew Thompson

Loek said:
Application running on a local network does not write. .......
The code for both paths, reading and writing is the same, the path + file is
Q:\\Opgaven.txt
Some code, to write to the file:
"
String abspad = fil.getAbsolutePath();
FileWriter fw = new FileWriter(abspad);

Given FileWriter accepts a File, why on earth would you convert
the File path to a String before passing it?

But to explain that better, please add it as a comment to
an SSCCE*, rather than post these snippets**.
In what direction I have to look for a solution for my problem ?

* Post something we can at least compile and run
(even if we need to get a network to see it fail).
The something I would prefer to see is an SSCCE..
<http://www.physci.org/codes/sscce/>

** Personal preference, but shared by at least a
few of the more helpful people.

Andrew T.
 
C

Chris Uppal

Loek said:
The exception is:
FileNotFoundException: Q:\\Opgaven.txt

You may have too many \'s there. I'm not sure how Windows will interpret a
path with double backslashes when the path is on a mapped network drive (and
especially if the drive is on a Novell server), but it seems at least possible
that it would fail.

In case it isn't already clear to you: you need to double-up \s when you type
them in Java source as part of a literal String, but that's just to tell the
compiler "yes, I do want a \ here"; the resulting String will have only one \.
So if you are creating Strings at runtime (e.g. reading them from a file, or
from user input) then there should only be one \ since the compiler won't be
getting in the way.

-- chris
 
L

Loek Raemakers

The 'why on earth ' reaction did help. Now I realise that I was not only just
writing to a file, but also creating a file. On a network!
This helps. Thanks to Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top