Victor Laerte
Victor Laerte

Reputation: 6556

Invalid character in zipfile path (Windows)

I have to unzip one file that contains a invalid path for Windows OS:

9f96bc3dE8d94fc2B1fd2ff9ed8d2637\html\portlet\facilit\planooperativo\themes\plano-operativo-theme\css\data:image

data:image, in windows it's not permited to be directory with : in path then my code to unzip got this exception java.io.IOException: The filename, directory name, or volume label syntax is incorrect

How can I fix it, changing : for another character (underline for example) or just skip this directory.

I've tried this code below, but it doesn't work:

while (ze != null) {
    String fileName = ze.getName();
    File newFile = new File(outputFolder + File.separator + fileName);

    String nameFile = newFile.getAbsolutePath();
    if (nameFile.contains(":")){
        nameFile.replaceAll(":", "_");
        newFile = new File(nameFile);
    }

actually my path needs to contain : because the complete path needs to begin with C:\, please give me one solution (Detail: it works fine in Mac)

Upvotes: 0

Views: 663

Answers (1)

Victor Laerte
Victor Laerte

Reputation: 6556

 while (ze != null) {
                String fileName = ze.getName();

                if (fileName.contains(":")){
                    fileName = fileName.replaceAll(":", "_");

                }

Upvotes: 1

Related Questions