わかりましたので、私が得たもの。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String test = null;
try {
test = refresh_all_data();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView day1Label = new TextView(this);
day1Label.setText(test);
setContentView(day1Label);
}
そして refresh_all_data(); 方法。
private String refresh_all_data() throws IOException
{
InputStream in = getAssets().open("data.txt");
//The buffered reader has a method readLine() that reads an entire line from the file, InputStreamReader is a reader that reads from a stream.
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//This is the StringBuilder that we will add the lines to:
StringBuilder sb = new StringBuilder(512);
String line;
//While we can read a line, append it to the StringBuilder:
while((line = reader.readLine()) != null){
sb.append(line);
}
//Close the stream:
reader.close();
//and return the result:
return sb.toString();
}
ジェイブに感謝します。