Extracting zipped file from ResourceStream throws error “Invalid stored block lengths”

后端 未结 3 1079
醉酒成梦
醉酒成梦 2020-12-11 15:23

I am trying to extract a ZIP file from my current JAR using:

InputStream resource = getClass().getClassLoader().getResourceAsStream(name);

3条回答
  •  悲哀的现实
    2020-12-11 16:10

    Thanks to @PaulBGD's answer above. It saved me hours to figure out what happened to my system I add the following new snippets into my pom.xml file (which I didn't realize is the root cause before reading Paul's answer):

    
      
        src/main/resources
        true
        
          **/*.version
          **/*.properties
          **/*.xml
          **/*.csv
          **/*.txt
          **/*.gif
          **/*.json
          **/*.xlsx
          rythm/**
        
      
    
    

    However I didn't take Paul's answer directly, instead I don't think those xlsx files should go through the resource plugin's filtering pipeline, thus I added another resource into pom:

      
        src/main/resources
        false
        
          **/*.xlsx
        
      
    

    And it fixed my problem without changing the source encoding setting from UTF-8 to ISO-8859-1

提交回复
热议问题