Maven build resource file copy failed.

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Maven build resource file copy failed.

Hi guys,

I come from China. I got an problem "Failed to copy full contents from..."
while using maven to build my project. Because there is an *.xlsx file in
the resources folder. This excel file contains some Chinese characters.

I have tried with add the following configuration in my pom.xls as below.
But it doesn't work.



I used "mvn -X clean compile" to build the porject and found the exception
was thrown in the line of following class.

FileUitl.copyFile(..) source code is :
private static void doCopyFile( @Nonnull File source, @Nonnull File
destination )
        throws IOException
        FileInputStream fis = null;
        FileOutputStream fos = null;
        FileChannel input = null;
        FileChannel output = null;
            fis = new FileInputStream( source );
            fos = new FileOutputStream( destination );
            input = fis.getChannel();
            output = fos.getChannel();
            long size = input.size();
            long pos = 0;
            long count;
            while ( pos < size )
                count = size - pos > FILE_COPY_BUFFER_SIZE ?
                pos += output.transferFrom( input, pos, count );
            IOUtil.close( output );
            IOUtil.close( fos );
            IOUtil.close( input );
            IOUtil.close( fis );

I tried with junit to call it directory and got the same result.
public void testFileCopy() throws IOException {
String path = "E:\\test";
String srcFilePath = path + "/my.xlsx";
String destFilePath = path + "/my2.xlsx";
File srcFile = new File(srcFilePath);
File destFile = new File(destFilePath);
FileUtils.copyFile(srcFile, destFile);
assertEquals(srcFile.length(), destFile.length());

But it was passed junit test by using the file copy by my own. The source
code is the following.

 * Copy a file to b file.
 * @param src
 * @param dest
 * @return True for successfully. False for failed or empty parameter.
 * @throws RrsException
public static boolean copy(File src, File dest) throws RrsException{
if (src == null || dest == null){
return false;
try (
OutputStream os = new FileOutputStream(dest);
write(src, os);
} catch (IOException e) {
String msg = MessageFormat.format("Cannot copy file from [{0}] to [{1}]",
src.getAbsolutePath(), dest.getAbsolutePath());
throw new RrsException(msg);
return true;

 * Write a file with BufferedOutputStream.
 * No close method called in this method for parameter 'os'.
 * The caller should be close it itself.
 * @param file
 * @param os
 * @throws RrsException
public static void write(File file, OutputStream os) throws RrsException{
BufferedOutputStream bos = new BufferedOutputStream(os);

try (
BufferedInputStream bis = new BufferedInputStream(new
) {
byte[] buffered = new byte[1024 * 256];
int len = 0;
int count = 0;
while((len = != -1){
bos.write(buffered, 0, len);
if (++count % 10 == 0){
} catch (Exception e) {
throw new RrsException(e.getMessage(), e);

Could any one have a check that what different between these two way for
copying file?
What configuration can be added to my project to fix the problem?

Thank you very much.