help me ,please(50分)

  • 主题发起人 主题发起人 fallinangry
  • 开始时间 开始时间
F

fallinangry

Unregistered / Unconfirmed
GUEST, unregistred user!
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class client
{
public static final int DEFAULT_PORT=6543;
//the port of the client
public static final void usage()
{
System.out.println("Usage:java Client <hostname> [<port>]");
System.exit(0);
}


public static void main(String args[])
{
int port=DEFAULT_PORT;
Socket s=null;
if ((args.length!=1)&amp;&amp;(args.length!=2))usage();
if (args.length==1)
port=DEFAULT_PORT;
else
{
try{port=Integer.parseInt(args[1]);
catch (NumberFormatException e) usage();
}

try{
s=new Socket(args[0],port);
DataInputStream sin=new DataInputStream(s.getInputStream());
PrintStream sout=new DataInputStream (s.getInputStream());
DataInputStream in=new DataInputStream(System.in);
System.out.println("Connected to"+s.getInetAddress()+":"+s.getPort());
String line;

for (;;)
{
System.out.print(">");
System.out.flush();
line=in.readLine();
if (line==null) break;
sout.println(line);
line=sin.readLine();
if (line==null)
{
System.out.println("Connection closed by aserver");
break;
}
System.out.println(line);
}
}
catch (IOException e ) {System.err.println(e);}
finally
{
try {if (s!=null) s.close();
catch( IOException e2);

}
}
}

 
请说明问题
 
没问怎么答?!
 
这是一个客户端程序,在编译过程中 老是提示try 没有catch 或catch 没try ?请问是怎么回事?谢谢
 
后退
顶部