File tarGzFile = new File(path + name + ".tar.gz");
if(!tarGzFile.exists()) {
System.out.println("This test is a bit slow. It needs to write 3GB of data as a compressed file (approx. 3MB) to your hard drive");
final PipedOutputStream outTarFileStream = new PipedOutputStream();
PipedInputStream inTarFileStream = new PipedInputStream(outTarFileStream);
Thread source = new Thread(){
@Override
public void run() {
byte ba_1k[] = new byte[(int) _1K];
for(int i=0; i < ba_1k.length; i++){
ba_1k[i]='a';
}
try {
TarArchiveOutputStream outTarStream =
(TarArchiveOutputStream)new ArchiveStreamFactory()
.createArchiveOutputStream(ArchiveStreamFactory.TAR, outTarFileStream);
// Create archive contents
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(name + ".txt");
tarArchiveEntry.setSize(fileSize);
outTarStream.putArchiveEntry(tarArchiveEntry);
for(long i = 0; i < fileSize; i+= ba_1k.length) {
outTarStream.write(ba_1k);
}
outTarStream.closeArchiveEntry();
outTarStream.close();
outTarFileStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}