2

So I want to create a .zip with the src of a project in (Using Maven Projects). First I get the sourceCode Header Folder with 'projectLocation + "/src/main"', and then get all Files of the Head File with

private static List<File> getAllFilesFromDir(File dir){

        List<File> files = new ArrayList<>();
        if(!dir.exists()) return files;

        for(File file : dir.listFiles()){
            if(file.isDirectory()){
                files.add(file);
                files.addAll(getAllFilesFromDir(file));
            }else{
                files.add(file);
            }
        }

        return files;
    }

And then I'm adding all those files in the List to the Zip

for(File file : allSrcFiles){
                ZipParameters parameters = new ZipParameters();
                parameters.setFileNameInZip("SourceCode/" + file.getAbsolutePath().substring(sourceCodePath.toCharArray().length));
                if(file.isDirectory()){
                    zipFile.addFolder(file, parameters);
                }else if(file.isFile()){
                    zipFile.addFile(file, parameters);
                }
            }

With that code tho, the folders get created without icon, and where a .java file is in, the folder gets created double with once a folder and once the text but with the same name as the folder

https://ibb.co/FbjzN9R

Mxrlin
  • 23
  • 6

0 Answers0