This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

File.toUrl, is this a bug?


Hello,

While running my application which I finnaly compiled and works 50-60% I
found a problem which can be easy replicated using the following piece of
code:

public class Main {

    public static void main(String[] args) {
        try{
            File file = new File(args[0]);
            URL url;
            if (file.exists()) {
                url = file.toURL();
            }else{
                url = new URL(args[0]);
            }
            URLConnection conn = url.openConnection();
                BufferedReader buf = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
                String line = buf.readLine();
                while(line!=null){
                    System.out.println("line = " + line);
                    line=buf.readLine();
                }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

If args[0] is a http address for example
(http://nemesisit.rdsnet.ro/index.shtml) everything works ok
If args[0] is a local file I get the following error:

java.io.FileNotFoundException: \c:\thisiscool-gcc\examples\reflect\list: The
filename, directory name, or volume label syntax is incorrect.

   at __ZN4Main4mainEP6JArrayIPN4java4lang6StringEE
(c:\thisiscool-gcc\examples\reflect\src\Main.java:19)
   at _main (c:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccEhbaaa.i)

Is this a bug?

Len


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]