Last active
December 23, 2015 23:59
-
-
Save StefanKruk/6713929 to your computer and use it in GitHub Desktop.
A Simple Java Programm that open a ServerSocket and asking for a number.
"\u001B[31m" make the Text Red
"\u001B[37m" make the Text White
This file contains hidden or 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
| import java.io.BufferedReader; | |
| import java.io.BufferedWriter; | |
| import java.io.InputStreamReader; | |
| import java.io.OutputStreamWriter; | |
| import java.net.ServerSocket; | |
| import java.net.Socket; | |
| public class Test | |
| { | |
| final static String SCREEN_CLR = "\u001B[2J"; | |
| final static String SCREEN_REP = "\u001B[1;1H"; | |
| public static void main(String[] args) throws Exception | |
| { | |
| String text = ""; | |
| ServerSocket s = new ServerSocket(23); | |
| Socket server = s.accept(); | |
| BufferedWriter out = new BufferedWriter(new OutputStreamWriter(server.getOutputStream())); | |
| BufferedReader in = new BufferedReader(new InputStreamReader(server.getInputStream())); | |
| while (!text.equals("stop")) | |
| { | |
| /* CLEAR the Console | |
| out.write("Bitte zahl eingeben: "); | |
| out.flush(); | |
| text = in.readLine(); | |
| System.out.println(text); | |
| out.write(SCREEN_CLR); | |
| out.flush(); | |
| out.write(SCREEN_REP); | |
| out.flush(); | |
| */ | |
| // Print the Number you send in Red in the Console | |
| out.write("Bitte zahl eingeben: "); | |
| out.flush(); | |
| text = in.readLine(); | |
| out.newLine(); | |
| out.write("\u001B[31m" + text + "\u001B[37m\n"); | |
| out.flush(); | |
| out.newLine(); | |
| } | |
| s.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment