【发布时间】:2015-01-01 19:09:36
【问题描述】:
我正在用java练习网络,我打算通过SocketChannel发送一个文件,主机和端口由用户指定。但是,当我声明变量时,Eclipse 会给出错误消息:
“令牌语法错误,删除这些令牌” 编辑:(此错误消息在端口和主机声明旁边弹出)
这是我的代码:
public int port;
public String host;
public class Client {
public static void main (String[] args) {
System.out.print("Enter host/ip: ");
Scanner inputHost = new Scanner(System.in);
host = inputHost.next();
System.out.print("Enter port: ");
Scanner inputPort = new Scanner(System.in);
port = inputPort.nextInt();
Client client = new Client();
SocketChannel channel = client.createChannel();
client.sendFile(channel);
【问题讨论】:
-
post和host变量都需要在Client类的范围内声明。 -
哦,对不起,愚蠢的错误
标签: java eclipse network-programming socketchannel