【发布时间】:2014-11-06 20:25:36
【问题描述】:
无法找到或阅读有关此问题的任何内容(这只是我的问题,但也许有人知道解决它的方法。
我有从资产文件夹读取的功能
public String[] loadFromAsset() throws IOException
{
String TEMPBUFFER = null;
String[] temp;
temp = new String[60];
int tempc = 0;
BufferedReader bReader = new BufferedReader(new InputStreamReader(cont.getAssets().open("myquests.txt")));
String line="";// = bReader.readLine();
StringBuilder sb = new StringBuilder();
while (line != null) {
line = bReader.readLine();
sb.append(line).append("TABTAB");
tempc++;
}
bReader.close();
//convert SB to array here
saveCount(tempc-1);
return temp;
}
需要返回字符串数组,例如 temp[50] = (1,2,3,4,5,...n+1) 但我找不到从 stringBuilder 转换为数组的方法:( 拜托,也许有人知道。告诉我
只需要将 SB 作为数组返回(如 temp[])或将 SB 转换为 Array,如 sb->convert->temp[]
【问题讨论】:
-
那你为什么首先使用stringbuilder呢?
-
您需要转换 temp 吗?
-
需要使用它将 StringBuilder 转换为 temp(字符串数组),因为它是最快的方式
-
它比什么更快?
-
sb 比我使用时更好更快: temp[tempc]=line; // 不知道为什么 - 但它比我使用 stringbuilder 需要更多时间
标签: android arrays string stringbuilder