Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.DataInputStream;
import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    private static boolean isRootOk(DataOutputStream output, DataInputStream input,
            final DataInputStream errInput) {
        if (output != null) {
            try {
                output.writeBytes("id\n");
                output.flush();
                String a = input.readLine();
                if (a.contains("root") || a.contains("uid=0")) {
                    return true;
                }
                new Thread() {
                    @Override
                    public void run() {
                        try {
                            errInput.read();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    };
                }.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return false;
    }
}