-1
我想通過基本的客戶端,服務器應用程序在新的一行輸出數組。但是,爲了實現這一點,我不得不使用子串來查找每個單詞後面的#以表示行結束。不過,我想刪除此功能,並將每一部分放在一個新行中。輸出新行無WITH循環
public ClientHandler(Socket socket,Users newUser, int newClientUser)
throws IOException
{
client = socket;
input = new Scanner(client.getInputStream());
output = new PrintWriter(
client.getOutputStream(),true);
user = newUser;
clientUser = newClientUser;
String[] itemName = {user.getItemName(1), user.getItemName(2)};
String[] description = {user.getItemDescription(1), user.getItemDescription(2)};
String[] itemtime = {user.getItemTime(1), user.getItemTime(2)};
output.println(itemName[0] + "@" + itemName[1]
+ "@" + "Welcome To The Auction User:" + clientUser
+ itemName[0] +": "+ description[0] +
"@"+ itemName[1] +": "+description[1]+
"@"+ "Deadline For " + itemName[0] + ": "
+ itemtime[0] + "#" +"Deadline For " +
itemName[1] + ": " + itemtime[1]+"@");
}
private synchronized void getMessage(String response)
{
String message="";
for(int i= count; !response.substring(i, i+1).equals("@"); i++)
{
count = i;
}
}
這有點難以理解你的問題,所以我盡我所能地盡力回答。 – DarkJade