PDF file with empty pages appearing after Copying using Java Files.copy

后端 未结 2 1877
迷失自我
迷失自我 2021-01-16 05:10

I am trying to copy a file in my Class path to another temp location.

Here is the code for it:

    InputStream inputStream = this.getClass().getClass         


        
2条回答
  •  天涯浪人
    2021-01-16 05:36

    Issue was totally unrelated. I was using maven copy resource to copy the resources under my src/main/resources/

    this was my maven resource:

            
                src/main/resources
                true
                
                    **/*.properties
                    **/*.xml
                    **/*.txt
                    **/*.html
                    **/*.pdf
                
            
    

    Since the filtering was on PDF file was copied as an empty doco to the target folder.

    I just seperated it into two resources with filtering off for PDF file.

            
                src/main/resources
                true
                
                    **/*.properties
                    **/*.xml
                    **/*.txt
                    **/*.html
                
            
            
                src/main/resources
                false
                
                    **/*.pdf
                
            
    

    Thanks to Drew Buckley, I got the issue when trying to do a binary comparison of the file. Actual file on the project was different and the one on the target folder which gets copied from the maven was different.

    It works fine now.

提交回复
热议问题