// Path: src/main/java/de/hartz/vpn/helper/OutputStreamHandler.java
// public class OutputStreamHandler extends Thread {
//     private InputStream inputStream;
//     private Logger listener;
//     private StringBuilder output = new StringBuilder();
// 
//     public OutputStreamHandler(InputStream inputStream) {
//         this.inputStream = inputStream;
//     }
// 
//     public OutputStreamHandler(InputStream inputStream, Logger listener) {
//         this.listener = listener;
//         this.inputStream = inputStream;
//     }
// 
//     public void run() {
//         try (Scanner br = new Scanner(new InputStreamReader(inputStream))) {
//             String line;
//             while (br.hasNextLine()) {
//                 line = br.nextLine();
//                 output.append(line).append(System.getProperty("line.separator"));
//                 if (listener != null)
//                     listener.addLogLine(line);
//             }
//         }
//     }
// 
//     public StringBuilder getOutput() {
//         /*
//         TODO: Check if this works always.
//         try {
//             inputStream.close();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }*/
//         return output;
//     }
// }


import de.hartz.vpn.helper.Linux;
import de.hartz.vpn.helper.OutputStreamHandler;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.prefs.Preferences;
            try {
                // SecurityException on Windows.
                preferences.put("foo", "bar");
                preferences.remove("foo");

                // BackingStoreException on Linux.
                preferences.flush();
                return true;
            } catch(Exception e) {
                return false;
            } finally{
                System.setErr(systemErr);
            }
        }
    }

    /**
     * Function that indicates whether the system uses apt as packet manager.
     * @return
     */
    @Linux
    public static boolean hasAPT() {
        ProcessBuilder pb = new ProcessBuilder("whereis", "apt");
        pb.redirectErrorStream(true);
        Process process = null;
        try {
            process = pb.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
// Path: src/main/java/de/hartz/vpn/helper/OutputStreamHandler.java
// public class OutputStreamHandler extends Thread {
//     private InputStream inputStream;
//     private Logger listener;
//     private StringBuilder output = new StringBuilder();
// 
//     public OutputStreamHandler(InputStream inputStream) {
//         this.inputStream = inputStream;
//     }
// 
//     public OutputStreamHandler(InputStream inputStream, Logger listener) {
//         this.listener = listener;
//         this.inputStream = inputStream;
//     }
// 
//     public void run() {
//         try (Scanner br = new Scanner(new InputStreamReader(inputStream))) {
//             String line;
//             while (br.hasNextLine()) {
//                 line = br.nextLine();
//                 output.append(line).append(System.getProperty("line.separator"));
//                 if (listener != null)
//                     listener.addLogLine(line);
//             }
//         }
//     }
// 
//     public StringBuilder getOutput() {
//         /*
//         TODO: Check if this works always.
//         try {
//             inputStream.close();
//         } catch (IOException e) {
//             e.printStackTrace();
//         }*/
//         return output;
//     }
// }


// Path: src/main/java/de/hartz/vpn/utilities/GeneralUtilities.java
import de.hartz.vpn.helper.Linux;
import de.hartz.vpn.helper.OutputStreamHandler;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.prefs.Preferences;

            try {
                // SecurityException on Windows.
                preferences.put("foo", "bar");
                preferences.remove("foo");

                // BackingStoreException on Linux.
                preferences.flush();
                return true;
            } catch(Exception e) {
                return false;
            } finally{
                System.setErr(systemErr);
            }
        }
    }

    /**
     * Function that indicates whether the system uses apt as packet manager.
     * @return
     */
    @Linux
    public static boolean hasAPT() {
        ProcessBuilder pb = new ProcessBuilder("whereis", "apt");
        pb.redirectErrorStream(true);
        Process process = null;
        try {
            process = pb.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
        OutputStreamHandler outputHandler = new OutputStreamHandler(process.getInputStream());