Datei einlesen

Hallo nochmal,

wieso geht dieses Konstrukt nicht? :

Code:
File f = new File(„C:\textprobe\textprobe.txt“);
FileReader fr = new FileReader(f);Ich habe es auch schon mit nur einem Slash usw. probiert.
Es kommt immer eine FileNotFoundException, obwohl die Datei natürlich existiert.

Lars

Hallo nochmal,

Versuch es nochmal so:

File f = new File("C:/textprobe/textprobe.txt");

Ansonsten, die FileNotFoundException wird nicht nur geschmissen,
wenn die Datei nicht vorhanden ist, sondern auch:

It will also be thrown by these constructors if the file does exist
but for some reason is inaccessible, for example when an attempt is
made to open a read-only file for writing.

http://java.sun.com/j2se/1.4.2/docs/api/java/io/File…

Gruss
Patrick

Gut, ich probier’s mal.

Nö, funzt leider nicht. Zugriff müsste für die Datei eigentlich ganz normal eingestellt sein.

Gruss, Lars

Also, wenn ich deinen Ursprungscode verwende, auf C einen
Ordner „textprobe“ und eine Datei namens „textprobe.txt“
anlege, dann funktioniert das bei mir wunderbar.

Gruss
Patrick