Autore Topic: leggere txt  (Letto 546 volte)

Offline froyo

  • Utente junior
  • **
  • Post: 81
  • Respect: +1
    • Mostra profilo
  • Dispositivo Android:
    desire
  • Sistema operativo:
    2.3
leggere txt
« il: 01 Dicembre 2011, 12:09:29 CET »
0
Salve ragazzi secondo voi cosa sbaglio nella lettura da file
Codice (Java): [Seleziona]
package com.android.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.FileNotFoundException;
import java.util.Date;



import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


import android.content.Context;
import android.os.Environment;
import android.widget.Toast;

public class read {
        public static File sd = Environment.getExternalStorageDirectory();
        public static File f = new File(sd, "intei.txt");
        static FileReader fr = null;
        static BufferedReader br = null;

        public static String main(String readString) {
                //String readString;
                try {
                        fr = new FileReader(f);
                        br = new BufferedReader(fr);
                        readString = br.readLine();
                        readString += br.readLine();
                        br.close();
                        fr.close();
                System.out.println("ciao"+readString);
                       
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        readString = "errore";
                }
                return readString;

}
       
}