Last active
February 26, 2020 07:48
-
-
Save cosminpopescu14/a9c5e04aab255811ef4b0d6349f09b34 to your computer and use it in GitHub Desktop.
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
static Runnable task = Main::socketPlay; | |
private static void socketPlay() { | |
int count = 0; | |
try (var serverSocket = new ServerSocket(80)){ | |
var socket = serverSocket.accept(); | |
try (var output = new PrintWriter(socket.getOutputStream(), true)) { | |
while (count <=10) { | |
output.println(generateRandomStrings()); | |
count++; | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
finally { | |
try { | |
socket.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} catch (IOException ex) { | |
ex.printStackTrace(); | |
} | |
} | |
//in main | |
task.run(); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The previous code was wrong.