Attachment 'Lettura.java'
Download 1 package fondamenti.files;
2
3 import java.io.BufferedReader;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.FileReader;
7 import java.io.IOException;
8 import java.io.InputStreamReader;
9
10
11 public class Lettura
12 {
13 public static void main(String[] args) {
14
15 try {
16 //Sostituire con un percorso valido sul proprio pc
17 FileReader f = new FileReader("/Users/ricca/Universit�/Didattica/Corsi/FondamentiSciBio/fondamenti/src/prova.txt");
18
19 BufferedReader lettore = new BufferedReader(f);
20
21 String riga = lettore.readLine();
22
23 while( riga != null)
24 {
25 System.out.println(riga);
26 riga = lettore.readLine();
27 }
28
29 f.close();
30
31 } catch (FileNotFoundException e) {
32 System.out.println("Il file non c'�!!!");
33 } catch (IOException e) {
34 System.out.println("C'� stato un errore di I/O");
35 }
36
37 }
38 }
Attached Files
You are not allowed to attach a file to this page.