'BufferedReader'에 해당되는 글 1건

  1. 2011.05.13 Android - read textfile in sdcard
posted by Solver Full-stack Developer 2011.05.13 17:46


File datafile = new File("/sdcard/filename.txt");
  StringBuilder data = new StringBuilder(); 
  try {    
   BufferedReader reader = new BufferedReader(new FileReader(datafile));    
   String readdata;     
   while ((readdata = reader.readLine())!=null) {        
    data.append(readdata); 
    }
   } catch (IOException e) {    
   }
  }



String tmp="";
String url="/sdcard/filename.txt";
  
  try {
   BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(url)), "UTF-8"));
   String line;     
   while ((line = br.readLine()) != null) {        
    tmp+=line;
   }
  } catch (IOException e) { 
  }


FileInputStream fis = new FileInputStream(url);
   Reader in = new InputStreamReader(fis, "UTF-16");
   String tmp="";
   char []buf = new char[fis.available()];
   in.read(buf);
   tmp = new String(buf);
   fis.close();

신고

티스토리 툴바