File.mkdir is not working and I can't understand why

Posted by gotch4 on Stack Overflow See other posts from Stack Overflow or by gotch4
Published on 2010-03-22T15:01:04Z Indexed on 2010/03/22 15:21 UTC
Read the original article Hit count: 314

Filed under:
|

Hello, I've this brief snippet:

String target = baseFolder.toString() + entryName;
                target = target.substring(0, target.length() - 1);
                File targetdir = new File(target);
                if (!targetdir.mkdirs()) {
                    throw new Exception("Errore nell'estrazione del file zip");
                }

doesn't mattere if I leave the last char (that is usually a slash). It's done this way to work on both unix and windows. The path is actually obtained from the URI of the base folder. As you can see from baseFolder.toString() (baseFolder is of type URI and is correct). The base folder actually exists. I can't debug this because all I get is true or false from mkdir, no other explanations.The weird thing is that baseFolder is created as well with mkdir and in that case it works.

Now I'm under windows.


the value of target just before the creation of targetdir is "file:/C:/Users/dario/jCommesse/jCommesseDB" if I cut and paste it (without the last entry) in windows explore it works...

© Stack Overflow or respective owner

Related posts about java

Related posts about filesystem