Friday, March 27, 2015

Android asset에서 텍스트 읽기

AssetManager assetManager = getAssets();
InputStream input;
String text = "";

try {
input = assetManager.open("text.txt");

int size = input.available();
byte[] buffer = new byte[size];
input.read(buffer);
input.close();

// byte buffer into a string
text = new String(buffer);

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

No comments:

Post a Comment