14

this is a really simple java question. I am using Java 8 with eclipse kepler on a linux system. I've been trying to try out NIO.2. My code is:

package lucasTest;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.*;

public class Lucas {
    public static void main(String[] args) throws URISyntaxException{
        URI u = new URI("./Lucas.java");
        Path p = Paths.get(u);  
    }
}

I get the following error:

Exception in thread "main" java.lang.IllegalArgumentException: Missing scheme
    at java.nio.file.Paths.get(Paths.java:134)
    at lucasTest.Lucas.main(Lucas.java:10)

Please help!

Thanks, Lucas

1

1 Answer 1

20

Your uri declaration is missing the scheme for files (file:///):

u = new URI("file:///./Lucas.java");
Path p = Paths.get(u);          

should work. As an alternative you can try

 Path p2 = Paths.get(".", "Lucas.java");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.