03.02.2015 Views

Input e Output in Java

Input e Output in Java

Input e Output in Java

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lettura<br />

●<br />

●<br />

Sia File<strong>Input</strong>Stream che FileReader<br />

hanno un metodo read() che serve per<br />

leggere un byte o un carattere (rispettivamente)<br />

alla volta<br />

In ogni caso entrambi i metodi restituiscono un<br />

<strong>in</strong>t:<br />

– se il valore restituito è –1 allora è stata raggiunta la<br />

f<strong>in</strong>e del file<br />

– Se il valore restituito è non negativo allora si può<br />

fare il cast<strong>in</strong>g a byte o a char (rispettivamente) per<br />

ottenere il valore letto<br />

Laboratorio di Programmazione - Luca Tesei<br />

19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!