Ciao.... sinceramente io non ho mai usato il DataInputStream, di solito ho sempre usato il Bufferedreader in questa maniera:
import java.io.*;
public class LeggiIO {
public static void main (String args[]) {
String s;
int integer = 0;
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(ir);
System.out.println("Unix: Type ctrl-d or ctrl-c per uscire." +
"\nWindows: Type ctrl-z per uscire");
try {
// Leggiamo ogni linea dell'ingresso.
s = in.readLine();
integer = Integer.parseInt(s);
while ( s != null ) {
System.out.println("Inserito: " + s+" Convertito:"+ integer);
s = in.readLine();
}
// Close the buffered reader.
in.close();
} catch (IOException e) { // Catch any IO exceptions.
e.printStackTrace();
}catch(NumberFormatException nf){
}
}
}
Spero ti si a utile...ciao
![]()

Rispondi quotando