Victor Laerte Oliveira Victor Laerte Oliveira - 23 days ago 11
Java Question

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)

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

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

                }