Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package dailyadviceclient;
- /**
- *
- * @author pablo
- */
- public class DailyAdviceClient {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Client client;
- client = new Client();
- client.go();
- }
- }
- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\/\/////////////////////////////
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package dailyadviceclient;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.Socket;
- /**
- *
- * @author pablo
- */
- public class Client {
- public Client(){
- }
- public void go() {
- try {
- Socket s;
- s = new Socket("127.0.0.1", 4242);
- InputStreamReader streamReader = new InputStreamReader(s.getInputStream());
- try (BufferedReader reader = new BufferedReader(streamReader)) {
- String advice;
- advice = reader.readLine();
- System.out.println("Today you should: " + advice);
- }
- } catch (IOException ex) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment