|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Aug 2008
Messaggi: 210
|
[Java] Leggere un file di testo da un server...
Salve. Avrei un problema alquanto strano, questo è un frammento del sorgente:
Codice:
String address = "http://" + Host + "/DFChat/server/messageList.txt";
Scanner reader = null;
try
{
URL url = new URL (address);
URLConnection connection = url.openConnection();
reader = new Scanner (connection.getInputStream());
while (reader.hasNext())
{
String timeMillis = reader.next();
String t = reader.next();
String user = reader.next();
String mess = reader.next();
if (timeMillis.compareTo (currentTimeMillis) > 0)
{
currentTimeMillis = timeMillis;
if (t.equals ("all") && !user.equals (username))
mainTextArea.append (user.replace ("_", " ") + " > " + mess.replace ("_", " ") + "\n");
}
}
}
catch (MalformedURLException exception)
{
JOptionPane.showMessageDialog (null, exception.getMessage(), "MalformedURLException", JOptionPane.ERROR_MESSAGE);
}
catch (IOException exception)
{
JOptionPane.showMessageDialog (null, exception.getMessage(), "IOException", JOptionPane.ERROR_MESSAGE);
}
catch (Exception exception)
{
JOptionPane.showMessageDialog (null, exception.getMessage(), "Exception", JOptionPane.ERROR_MESSAGE);
}
|
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Aug 2008
Messaggi: 210
|
Ora non mi funziona neanche più dal locale... bho non ci sto capendo nulla.
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 07:22.



















