@edu.umd.cs.findbugs.annotations.SuppressWarnings({"DM_DEFAULT_ENCODING", "OS_OPEN_STREAM"})
    private static void getUlimit(PrintWriter writer) throws IOException {
        // TODO should first check whether /bin/bash even exists
        InputStream is = new ProcessBuilder("bash", "-c", "ulimit -a").start().getInputStream();
        try {
            // this is reading from the process so platform encoding is correct
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                writer.println(line);
            }
        } finally {
            is.close();
        }
    }
@ edu . umd . cs . findbugs . annotations . SuppressWarnings ( { "DM_DEFAULT_ENCODING" , "OS_OPEN_STREAM" } ) private static void getUlimit ( PrintWriter writer ) throws IOException { InputStream is = new ProcessBuilder ( "bash" , "-c" , "ulimit -a" ) . start ( ) . getInputStream ( ) ; try { BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( is ) ) ; String line ; while ( ( line = bufferedReader . readLine ( ) ) != null ) { writer . println ( line ) ; } } finally { is . close ( ) ; } }
This method executes the command "bash -c ulimit -a" on the machine.