悟
悟峰
Unregistered / Unconfirmed
GUEST, unregistred user!
JCreator編輯,代碼如下:
import java.io.*;
import java.net.*;
public class Client
{
public static void main(String[] args)
{
int port=8000;
String inString;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
try
{
InetAddress address=new InetAddress.getByName(null);
Socket socket=new Socket(address,port);
OutputStream os=socket.getOutputStream();
OutputStreamWriter osw=new OutputStreamWriter(os);
PrintWriter pw=new PrintWriter(osw);
while ((inString=br.readLine())!=null)
{
pw.println(inString);
pw.flush();
if (inString.trim().equals("quit"))
System.exit(0);
}
}
catch (IOException e)
{
System.err.println(e);
}
}
}
編寫的Server則正常,何故提示信息如下:
--------------------Configuration: Client - JDK version 1.3.1_04 <Default>--------------------
C:/Program Files/Xinox Software/JCreator Pro/MyProjects/Helloworld3/variableclass/customer/cathcdemo/labeldemo/labeldemo/uselistenerdemo/hello/Client/Client.java:27: cannot resolve symbol
symbol : class getByName
location: class java.net.InetAddress
InetAddress address=new InetAddress.getByName(null);
^
1 error
Process completed.
按道理說,getByName()應該在java.net.*這個包里面啊?
import java.io.*;
import java.net.*;
public class Client
{
public static void main(String[] args)
{
int port=8000;
String inString;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
try
{
InetAddress address=new InetAddress.getByName(null);
Socket socket=new Socket(address,port);
OutputStream os=socket.getOutputStream();
OutputStreamWriter osw=new OutputStreamWriter(os);
PrintWriter pw=new PrintWriter(osw);
while ((inString=br.readLine())!=null)
{
pw.println(inString);
pw.flush();
if (inString.trim().equals("quit"))
System.exit(0);
}
}
catch (IOException e)
{
System.err.println(e);
}
}
}
編寫的Server則正常,何故提示信息如下:
--------------------Configuration: Client - JDK version 1.3.1_04 <Default>--------------------
C:/Program Files/Xinox Software/JCreator Pro/MyProjects/Helloworld3/variableclass/customer/cathcdemo/labeldemo/labeldemo/uselistenerdemo/hello/Client/Client.java:27: cannot resolve symbol
symbol : class getByName
location: class java.net.InetAddress
InetAddress address=new InetAddress.getByName(null);
^
1 error
Process completed.
按道理說,getByName()應該在java.net.*這個包里面啊?