MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / zip

Method zip

java/src/org/openqa/selenium/io/Zip.java:45–56  ·  view source on GitHub ↗
(File input)

Source from the content-addressed store, hash-verified

43 private static final int BUF_SIZE = 16384; // "big"
44
45 public static String zip(File input) throws IOException {
46 try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
47 try (ZipOutputStream zos = new ZipOutputStream(bos)) {
48 if (input.isDirectory()) {
49 addToZip(input.getAbsolutePath(), zos, input);
50 } else {
51 addToZip(input.getParentFile().getAbsolutePath(), zos, input);
52 }
53 }
54 return Base64.getEncoder().encodeToString(bos.toByteArray());
55 }
56 }
57
58 private static void addToZip(String basePath, ZipOutputStream zos, File toAdd)
59 throws IOException {

Callers 6

canUploadAFileMethod · 0.95
testCanZipASingleFileMethod · 0.95
testCanZipADirectoryMethod · 0.95
uploadMethod · 0.95
toJsonMethod · 0.95
getDownloadedFileMethod · 0.95

Calls 4

addToZipMethod · 0.95
getEncoderMethod · 0.80
toByteArrayMethod · 0.80
isDirectoryMethod · 0.65

Tested by 3

canUploadAFileMethod · 0.76
testCanZipASingleFileMethod · 0.76
testCanZipADirectoryMethod · 0.76