我正在处理一个项目,在该项目中,我必须从文件中读取数据并将该数据存储到字符串数组中。如何从字符串中提取特定字符
字符串数组位置“0”应该有文件的前13个字符,字符串数组位置“1”应该有文件的后13个字符。 我试图用getchar()只读取前13个字符,但我使用它时遇到了麻烦,有人可以指出我的错误,因为当我尝试在应用程序上运行该应用程序时,应用程序崩溃。
InputStream is = getResources().openRawResource(R.raw.temp);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
try {
while((string = br.readLine()) != null){
string.getChars(0,13, buffer, 0);
String str = new String(buffer);
text.setText(str);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
这里,buffer是一个char型数组。
什么是期望的语言? – pikausp 2014-08-31 20:08:02
是Java还是什么? – qbit 2014-08-31 20:08:42
是的,它的Java,我正在做Android编程,我是新来的。 – Asad 2014-08-31 20:15:17