format报错
package com.chatroom;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class ServerChat {
public static void main(String[] args){
new ServerChat().startUp();
}
public void startUp(){
ServerSocket ss= null;
Socket s= null;
String name = "[%s:%s"];
//后面放端口
try {
ss=new ServerSocket(12345);
System.out.println("服务器已启动...");
s = ss.accept();
System.out.println(String.format(name,s.getInetAddress().getHostAddress(),s.getPort()));
} catch (IOException e) {
e.printStackTrace();
} finally{
try {
if (s!=null) ss.close();
if (ss!=null) s.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}