UnknownSoldier
08-08-2008, 19:33
Salve. Avrei un problema alquanto strano, questo è un frammento del sorgente:
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);
}
Se provo il programma in locale, riesco a leggere correttamente il file di testo. Se invece lo provo uppato da qualche parte, non riesco a leggere niente... e la cosa strana è che non viene lanciata nessuna eccezione! Eppure ho settato tutti i privilegi di lettura/scrittura al massimo... non riesco a spiegarmi perchè questa differenza locale/server. Qualcuno di voi avrebbe un'idea? ;)
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);
}
Se provo il programma in locale, riesco a leggere correttamente il file di testo. Se invece lo provo uppato da qualche parte, non riesco a leggere niente... e la cosa strana è che non viene lanciata nessuna eccezione! Eppure ho settato tutti i privilegi di lettura/scrittura al massimo... non riesco a spiegarmi perchè questa differenza locale/server. Qualcuno di voi avrebbe un'idea? ;)