+
+ public static String getDataHomeDir() {
+ String dataHome = System.getenv("XDG_DATA_HOME");
+ if (dataHome != null) {
+ return dataHome;
+ }
+
+ return System.getProperty("user.home") + "/.local/share";
+ }
+
+ public static void copyStreamToFile(InputStream input, File outputFile) throws IOException {
+ copyStreamToFile(input, outputFile, 8192);
+ }
+
+ public static void copyStreamToFile(InputStream input, File outputFile, int bufferSize) throws IOException {
+ try (OutputStream output = new FileOutputStream(outputFile)) {
+ byte[] buffer = new byte[bufferSize];
+ int read;
+
+ while ((read = input.read(buffer)) != -1) {
+ output.write(buffer, 0, read);
+ }
+ }
+ }