Skip to content

Commit

Permalink
undo last few commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jul 20, 2023
1 parent 2a02934 commit 221cd47
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions karate-core/src/main/java/com/intuit/karate/job/JobUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.function.Predicate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
Expand Down Expand Up @@ -78,18 +75,13 @@ private static void zip(File fileToZip, String fileName, ZipOutputStream zipOut,
}
ZipEntry zipEntry = new ZipEntry(fileName);
zipOut.putNextEntry(zipEntry);
RandomAccessFile reader = new RandomAccessFile(fileToZip.getAbsolutePath(), "r");
FileChannel fc = reader.getChannel();
int bufferSize = 1024;
if (bufferSize > fc.size()) {
bufferSize = (int) fc.size();
FileInputStream fis = new FileInputStream(fileToZip);
byte[] bytes = new byte[1024];
int length;
while ((length = fis.read(bytes)) >= 0) {
zipOut.write(bytes, 0, length);
}
ByteBuffer bb = ByteBuffer.allocate(bufferSize);
while (fc.read(bb) > 0) {
zipOut.write(bb.array(), 0, bb.position());
bb.clear();
}
reader.close();
fis.close();
}

public static void unzip(File src, File dest) {
Expand Down Expand Up @@ -137,4 +129,4 @@ public static File getFirstFileMatching(File parent, Predicate<String> predicate
return files == null || files.length == 0 ? null : files[0];
}

}
}

0 comments on commit 221cd47

Please sign in to comment.