FileNotFoundException even though the file is there?
FileNotFoundException even though the file is there?
I am trying to copy and paste a Minecraft World from a template into the server folder and then load the world. I am getting this error:
java.io.FileNotFoundException:
.C:UsersArchieDesktopServer.b571c7a6-3297-48eb-ac24-1bac65ef9727session.lock
(The filename, directory name, or volume label syntax is incorrect)
So here is what I tried:
Printing out the source of the path and then the place I am copying it to, to console to check it is the correct path, here is what was printed:
C:UsersArchieDesktopServer.b571c7a6-3297-48eb-ac24-1bac65ef9727 (dir to copy to)
C:UsersArchieDesktopServerpluginsSolusgameworld (src)
That is correct. And in that folder the session.lock is literally there:
http://prntscr.com/klc7xp
So I am really confused as to why it is throwing a file not found exception, I've googled it but there doesn't really seem to be a fix.
Here is the code:
private void loadWorld()
File game = new File(Solus.get().getServer().getWorldContainer().getAbsolutePath() + uuid.toString());
if (!game.mkdir())
System.out.println("Couldn't generate the game: " + uuid.toString());
File srcDir = new File(Solus.get().getDataFolder().getAbsolutePath() + File.separator + "gameworld");
System.out.println(game.getPath() + " : " + srcDir.getAbsolutePath());
try
FileUtils.copyDirectory(srcDir, game);
catch (IOException e)
e.printStackTrace();
WorldCreator wc = new WorldCreator(game.getAbsolutePath());
wc.createWorld();
this.world = Bukkit.getServer().createWorld(wc);
Code explanation:
.C:
C:
try to debug it after removing the lock and while the file is locked, check if you are getting the same exception? stackoverflow.com/questions/1500174/…
– Vishrant
Aug 21 at 18:52
Specifically
.somefilename is telling java to look for somefilename in the local directory, so don't tell it to do that. Create a String filename = ....; and pass that to new File(filename), so you can use System.out.println() to see whether it's actually creating the right kind of filepath or not. Right now, it's creating a relative path instead of an absolute one.– Mike 'Pomax' Kamermans
Aug 21 at 18:52
.somefilename
somefilename
String filename = ....;
new File(filename)
System.out.println()
Mike, this is what I have done, String path = game.getAbsolutePath(); System.out.println("PATH:" + path); WorldCreator wc = new WorldCreator(path); It is still doing exactly the same error, nothing has changed. Any help?
– Archie
Aug 21 at 19:07
The actual directory is
Server.b571c7a6-3297-48eb-ac24-1bac65ef9727 but you've got Server.b571c7a6-3297-48eb-ac24-1bac65ef9727. You're missing a separator.– Klitos Kyriacou
Aug 21 at 20:02
Server.b571c7a6-3297-48eb-ac24-1bac65ef9727
Server.b571c7a6-3297-48eb-ac24-1bac65ef9727
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Nope, assertion is wrong -
.C:is notC:. The file really doesn't exist at that path. That should be sufficient information to fix the issue.– user2864740
Aug 21 at 18:50