Console类?

csforgood 2004-11-20 09:06:36
这是书上的一个例子,我javac EchoClient的时候提示 cannot resolve symble
symble: variable Console 请高手帮帮忙
import java.net.*;
import java.io.*;

public class EchoClient
{ public static void main(String args[])
{ try { Socket connection = new Socket(args[0],7);
System.out.println("Connection established:");
DataInputStream in = new DataInputStream(connection.getInputStream());
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
String line = new String("");
while(!line.toUpperCase().equals(".QUIT"))
{ System.out.println("Enter string:");
line = Console.readString();
System.out.println("\t Sending string to server");
out.writeUTF(line);
System.out.println("\t Waiting for server response...");
line = in.readUTF();
System.out.println("Received:"+line);
}
in.close();
out.close();
connection.close();
}
catch(UnknownHostException uhe){System.out.println("Unknown host:"+args[0]);}
catch(IOException ioe){System.out.println("IOEception:"+ioe);}
}
}
...全文
113 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
straightforward 2004-12-09
  • 打赏
  • 举报
回复
你这个程序如果是从书上摘下来的, 那应该在前面, 作者可能在某个程序中有自己定义了Console类,然后在这个程序中, 将它import进来了.
jFresH_MaN 2004-11-21
  • 打赏
  • 举报
回复
呵呵你以为是dotNet啊?
chenhagi_0 2004-11-21
  • 打赏
  • 举报
回复
console这个关键字没有了吧
xyj0323 2004-11-20
  • 打赏
  • 举报
回复
从报的错来说,应该是Console这个关键字用错了。
javafaq2004 2004-11-20
  • 打赏
  • 举报
回复
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println(in.readLine());
}catch(IOException e){}
javafaq2004 2004-11-20
  • 打赏
  • 举报
回复
你以为是dotNet啊?

line = Console.readString();

System.in

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧