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]
# 1
try file://<spec>
joachimkroeger2 at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

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.

mgregori at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
I don't know...sorry.Maybe: try a FileReader class to load the file.
joachimkroeger2 at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
reading more carefully; do you try to fetch via IP from a web host? Or a local file? From within an applet of an app?
joachimkroeger2 at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
From within an app. I'm trying to get a file from within an app in a HP Jornada 680 through a serial connection to a desktop PC with Windows 2000.
mgregori at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
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.
joachimkroeger2 at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

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.

mgregori at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8

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".

mgregori at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 9
I am confused..just a simple "/filename" should work with the FileReader class.Joachim
joachimkroeger2 at 2007-6-29 9:06:44 > top of Java-index,Java Mobility Forums,Java ME Technologies...