lrdblk Posted March 2, 2017 Share Posted March 2, 2017 Im trying to write to a file using this code try { Files.write(Paths.get(ClassLoader.getSystemResource("output.txt").getPath()), username.getBytes(), StandardOpenOption.APPEND); }catch (IOException e){ printOut(e.getLocalizedMessage()); } But im getting this error Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/stabo/IdeaProjects/ACC/out/production/ACC/output.txt at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94) at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255) at java.nio.file.Paths.get(Paths.java:84) at main.Main.main(Main.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Whats wrong with my path? Quote Link to comment Share on other sites More sharing options...