Hi, adding -Dfile.encoding=UTF-8 causes the below exception when adding entry to the tra file. java.io.IOException: request to write '198' bytes exceeds size in header of '111' bytes for entry '././@LongLink' at org.apache.tools.tar.TarOutputStream.write(TarOutputStream.java:280) at org.apache.tools.tar.TarOutputStream.write(TarOutputStream.java:261) at org.apache.tools.tar.TarOutputStream.putNextEntry(TarOutputStream.java:185)
piece of code: final TarOutputStream tarFile = new TarOutputStream(new FileOutputStream(pathName)); tarFile.setLongFileMode(TarOutputStream.LONGFILE_GNU); .... TarEntry tarEntry = new TarEntry(path); tarEntry.setSize(new File(pre_path+path).length()); tarFile.putNextEntry(tarEntry); in = new FileInputStream(convertPath(choosedAudioPath)+path); while((len = in.read(buf)) > 0) tarFile.write(buf, 0, len); tarFile.closeEntry(); in.close();
(In reply to comment #1) > piece of code: > > final TarOutputStream tarFile = new TarOutputStream(new > FileOutputStream(pathName)); > tarFile.setLongFileMode(TarOutputStream.LONGFILE_GNU); > > .... > > TarEntry tarEntry = new TarEntry(path); > tarEntry.setSize(new File(pre_path+path).length()); > tarFile.putNextEntry(tarEntry); > in = new FileInputStream(convertPath(choosedAudioPath)+path); > while((len = in.read(buf)) > 0) > tarFile.write(buf, 0, len); > > tarFile.closeEntry(); > in.close(); sorry, small mistake. it is: in = new FileInputStream(pre_path+path); instead of: in = new FileInputStream(convertPath(choosedAudioPath)+path);
it stops with a non-ASCII names (Arabic file name) while setting -Dfile.encoding=UTF-8. does it support adding UTF8 names?
the same bug has been solved in: http://jira.codehaus.org/browse/PLXCOMP-195 please check the patch applied there and consider apply the same to resolve this. When a TAR file is being written, and: 1. One or more filenames are so long that they require GNU mode 2. The platform encoding is UTF-8 3. Any character in a long filename results in a multibyte UTF-8 sequence then an exception is thrown with this text: "Problem creating TAR: request to write 'xxx' bytes exceeds size in header of 'xxx' bytes"
This issue is been solved in 1.9 with the new TarOutputStream(FileOutputStream, "UTF8") constructor and setLongFileMode(TarOutputStream.LONGFILE_GNU);