MCPcopy Index your code
hub / github.com/VolmitSoftware/Adapt / IO

Class IO

src/main/java/com/volmit/adapt/util/IO.java:32–1513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30import java.util.zip.ZipFile;
31
32public class IO {
33 /**
34 * The Unix directory separator character.
35 */
36 public static final char DIR_SEPARATOR_UNIX = '/';
37 /**
38 * The Windows directory separator character.
39 */
40 public static final char DIR_SEPARATOR_WINDOWS = '\\';
41 /**
42 * The system directory separator character.
43 */
44 public static final char DIR_SEPARATOR = File.separatorChar;
45 /**
46 * The Unix line separator string.
47 */
48 public static final String LINE_SEPARATOR_UNIX = "\n";
49 /**
50 * The Windows line separator string.
51 */
52 public static final String LINE_SEPARATOR_WINDOWS = "\r\n";
53 /**
54 * The system line separator string.
55 */
56 public static final String LINE_SEPARATOR;
57
58 /**
59 * The default buffer size to use.
60 */
61 private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
62 private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
63
64 static {
65 // avoid security issues
66 StringWriter buf = new StringWriter(4);
67 PrintWriter out = new PrintWriter(buf);
68 out.println();
69 LINE_SEPARATOR = buf.toString();
70 }
71
72 public static String decompress(String gz) throws IOException {
73 ByteArrayInputStream bin = new ByteArrayInputStream(Base64.getUrlDecoder().decode(gz));
74 GZIPInputStream gzi = new GZIPInputStream(bin);
75 ByteArrayOutputStream boas = new ByteArrayOutputStream();
76 IO.fullTransfer(gzi, boas, 256);
77 gzi.close();
78
79 return boas.toString(StandardCharsets.UTF_8);
80 }
81
82 public static byte[] sdecompress(String compressed) throws IOException {
83 ByteArrayInputStream bin = new ByteArrayInputStream(Base64.getUrlDecoder().decode(compressed));
84 GZIPInputStream gzi = new GZIPInputStream(bin);
85 ByteArrayOutputStream boas = new ByteArrayOutputStream();
86 IO.fullTransfer(gzi, boas, 256);
87 gzi.close();
88
89 return boas.toByteArray();

Callers

nothing calls this directly

Calls 2

toCharArrayMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected