codice:
/**
* @author menphisx
* @copy (c) author 2007/2009
* @version 1.0b
*
*/
import java.io.*;
import java.net.*;
public class RJClient {
/**
* RJC is an acronim for Remote Java Compiler.
* The idea is to create a class of server that can compile whit gcc,
* on every type of OS and architeture.
* The clients send sources and the server compile it.
*/
Socket client;
DataInputStream serverStream;
DataOutputStream clientStream;
BufferedReader stdin;
String request;
String response;
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
new RJClient(args[0], Integer.parseInt(args[1]));
}
catch(NumberFormatException nfe){
System.out.println("The port you typed is not a number");
}
}
public RJClient(String ip, int port) {
try{
Connect(ip, port);
}
catch(IOException ioe){
System.out.println("IOException During Connect() : " + ioe.getMessage());
}
}
public void Connect(String ip, int port) throws IOException {
client = new Socket(ip, port);
serverStream = new DataInputStream(client.getInputStream());
clientStream = new DataOutputStream(client.getOutputStream());
stdin = new BufferedReader(new InputStreamReader(System.in));
clientStream.writeBytes("ID:RJ");
while(true){
System.out.print("RJCLIENT:> ");
String request = stdin.readLine();
clientStream.writeBytes(request);
response = serverStream.readLine();
if(response.equals("SEE YOU SOON")){
System.out.println("bye bye\n");
System.exit(0);
}
System.out.println(response);
}
serverStream.close();
clientStream.close();
client.close();
}
}
Non riesco a compilarlo, mi restituisce:
codice:
RJClient.java:80: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
response = serverStream.readLine();
^
RJClient.java:94: unreachable statement
clientStream.close();
^
1 error
1 warning
Grazie per l'aiuto.