Last active
February 7, 2019 13:18
-
-
Save mritunjay-k/dc03809e48b443f079a56f66b98a75fc to your computer and use it in GitHub Desktop.
This is how you make your own terminal like a BOSS !!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Your temporary Terminal. | |
import java.io.*; | |
import java.util.Scanner; | |
public class Mycontrol{ | |
public static void main(String[] args){ | |
try{ | |
Scanner sc=new Scanner(System.in); | |
System.out.println("Enter a command"); | |
String cmd= sc.next(); | |
Runtime run= Runtime.getRuntime(); | |
Process pr= run.exec(cmd); | |
pr.waitFor(); | |
BufferedReader buf= new BufferedReader(new InputStreamReader(pr.getInputStream())); | |
String line= " "; | |
while((line=buf.readLine())!=null){ | |
System.out.println(line); | |
} | |
} | |
catch(Exception e){ | |
System.out.println("Command not found"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment