file io
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public String readRawFile(int rawFile){
StringBuffer buffer = new StringBuffer();
try{
InputStream inpstr =getResources().openRawResource(rawFile);
BufferedReader in = new BufferedReader(new InputStreamReader(inpstr);
while ((line = in.readLine()) != null) {
buffer.append(line);
}
in.close();
inpstr.close();
}catch(Exception exc){exc.printStackTrace();}
return buffer.toString();
}
String str = readRawFile(R.raw.some_raw_file_id);
import java.io.BufferedReader;
import java.io.InputStreamReader;
public String readRawFile(int rawFile){
StringBuffer buffer = new StringBuffer();
try{
InputStream inpstr =getResources().openRawResource(rawFile);
BufferedReader in = new BufferedReader(new InputStreamReader(inpstr);
while ((line = in.readLine()) != null) {
buffer.append(line);
}
in.close();
inpstr.close();
}catch(Exception exc){exc.printStackTrace();}
return buffer.toString();
}
String str = readRawFile(R.raw.some_raw_file_id);
Comments