Java File URI error ?

Posted by Frank on Stack Overflow See other posts from Stack Overflow or by Frank
Published on 2010-04-06T20:28:19Z Indexed on 2010/04/06 20:33 UTC
Read the original article Hit count: 548

Filed under:
|
|

I need to get a file object online, and I know the file is located at : http://nmjava.com/Dir_App_IDs/Dir_GlassPaneDemo/GlassPaneDemo_2010_04_06_15_00_SNGRGLJAMX

If I paste it into my browser's url, I'll be able to download this file, now I'm trying to get it with Java, my code looks like this :

String File_Url="http://nmjava.com/Dir_App_IDs/Dir_GlassPaneDemo/GlassPaneDemo_2010_04_06_15_00_SNGRGLJAMX";
Object myObject=Get_Online_File(new URI(File_Url));

Object Get_Online_File(URI File_Uri) throws IOException
{
  return readObject(new ObjectInputStream(new FileInputStream(new File(File_Uri))));
}

public static synchronized Object readObject(ObjectInput in) throws IOException
{
  Object o;
  ......
  return o;
}

But I got the following error message :

java.lang.IllegalArgumentException: URI scheme is not "file"
        at java.io.File.<init>(File.java:366)

Why ? How to fix it ?

Frank

© Stack Overflow or respective owner

Related posts about java

Related posts about file