【发布时间】:2018-08-10 17:32:42
【问题描述】:
InetAddress ipAddr;
我在这里要做的是我需要获取 ip 地址,然后将其放入套接字中
public class L implements ActionListener{
public void actionPerformed(final ActionEvent e){
try {
s = new Socket(ipAddr.getHostAddress(), 6111);
DataOutputStream dout = new DataOutputStream(s.getOutputStream());
dout.writeUTF("L");
dout.writeUTF(" ");
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
我有这个错误消息
线程“AWT-EventQueue-0”java.lang.NullPointerException 中的异常
【问题讨论】:
标签: java sockets nullpointerexception network-programming ip-address