Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import java.io.IOException;
public class Test
{
System.out.println("Hello World!... press enter.");
try{System.in.read();}catch(IOException e){}
System.out.println("You pressed enter. Press again to clear the console...");
try{System.in.read();
System.in.read();}catch(IOException e){}
for(int i=0;i<24;i++) System.out.println("");
System.out.println("Console cleared...");
System.out.println("Press again to exit...");
try{System.in.read();
System.in.read();}catch(IOException e){}
System.exit(0);
}
}
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.DataOutputStream;
import java.io.IOException;
public class Consola extends JFrame implements KeyListener, Runnable
{
private PipedOutputStream out;
private PipedInputStream out_in;
private PipedInputStream in;
private PipedOutputStream in_out;
private DataOutputStream in_outWriter;
private BufferedReader out_inReader;
private JTextArea consola=new JTextArea();
private Thread internal=new Thread(this);
private int charCount=0;
public void clear(){
consola.replaceRange("", 0, charCount);
charCount=0;
}
public Consola(){
try{
this.out_in=new PipedInputStream();
this.out=new PipedOutputStream(out_in);
this.in=new PipedInputStream();
this.in_out=new PipedOutputStream(in);
}catch(IOException e){
System.out.println("Excepcion: \n"+e);
}
out_inReader = new BufferedReader(new InputStreamReader(out_in));
in_outWriter=new DataOutputStream(in_out);
System.setIn((InputStream)in);
System.setOut(new PrintStream(out));
//SWING
this.getContentPane().setLayout(null);
setTile("Intercepted Console")
setBounds(100,100,400,500);
consola.setBounds(0,0,400,500);
this.getContentPane().add(consola);
consola.addKeyListener(this);
consola.setEditable(false);
consola.setBackground(Color.black);
consola.setForeground(Color.white);
internal.start();
show();
}
public void run(){
while(true){
try{
String input="";
input=""+out_inReader.readLine();
consola.append(""+input+"\n");
charCount+=input.length()+1; // +1: the \n
}catch(IOException e){}
}
}
public void keyTyped(KeyEvent e){
try{
in_outWriter.writeChar(e.getKeyChar());
}catch(IOException ioe){}
}
public void keyPressed(KeyEvent e){}
public void keyReleased(KeyEvent e){}
}
import java.io.IOException;
public class Test
{
Consola console = new Consola();
System.out.println("Hello World!... press enter.");
try{System.in.read();}catch(IOException e){}
System.out.println("You pressed enter. Press again to clear the console...");
try{System.in.read();
System.in.read();}catch(IOException e){}
console.clear();
System.out.println("Console cleared...");
System.out.println("Press again to exit...");
try{System.in.read();
System.in.read();}catch(IOException e){}
System.exit(0);
}
}
import java.io.IOException;
public class Test
{
public static void main(String peter[]){
Consola console = new Consola();
System.out.println("Hello World!... press enter.");
try{System.in.read();}catch(IOException e){}
System.out.println("You pressed enter. Press again to clear the console...");
try{System.in.read();
System.in.read();}catch(IOException e){}
console.clear();
System.out.println("Console cleared...");
System.out.println("Press again to exit...");
try{System.in.read();
System.in.read();}catch(IOException e){}
System.exit(0);
}
}