UNC Paths
Hello,
I'm trying to copy a file from a host through an UNC path in a Personal Java 1.0 environment.
I can see the host directories and files using the explorer of Windows CE, but, when I use FileInputStream I obtain always an FileNotFoundException.
I've tried it with this paths :
"//host/directory/data.df"
"\\\\host\\directory\\data.df" and even
File.separator + File.separator + "host" + File.separator + "directory" + File.separator + "data.df".
Thanks,
Marcos Gregori.
[552 byte] By [
mgregori] at [2007-9-26 2:12:55]

Thanks Joachim, but I've tried it and it not works.
In the explorer a path like '\\<spec>' works, but one of the type '//file:/<spec>' don't.
Are you sure that we can use an UNC path in a Windows CE environment? Or perhaps this is a Personal Java limitation.
Did you try the FileReader class?It should be able to open a local file. As I understood, this is your first step. When you have this running, you will need to use one of the streaming classes, depending on your required connection.
Yes I did.
The FileReader class reacts like FileInputStream : a FileNotFoundException.
Searching an alternate approach I've tried the URL class :
URL url = new URL( "file://host/file.df" );
InputStream is = url.openStream();
int available = is.available();
Well, here are the results :
Using the JVM 1.3.1 all works ok. The InputStream is created and the variable 'available' value is 3876 (the file size).
Using the Personal Java Emulator on Windows 2000, the result is a ConnectException with a "Connection refused" message.
And finally, running the app on Windows CE, the result is the same : a ConnectException.
I'm confused.
More tests :
URL( "////host//file.df" ) works ok on the Personal Java Emulator, but fails on the HandHeld : the result is a FileNotFoundException "\\host\\file.df" (look at the second double backslash).
URL("////host/file.df" ) returns a FileNotFoundException but the file name is now "\\host\file.df".