我想從資產文件夾中加載文件,並使用在停用詞procces一個字符串,這個INI我的代碼,但我得到錯誤「無法從BufferedReader中轉換爲字符串」不能從BufferedReader中轉換爲字符串
public void onClick(View v) {
// TODO Auto-generated method stub
if (v.getId()==R.id.button6){
StringBuilder text = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(getAssets().open("Preposisi.txt"), "UTF-8"));
// do reading, usually loop until end of file reading
String mLine = reader.readLine();
while (mLine != null) {
//process line
mLine = reader.readLine();
}
reader.close();
} catch (IOException e) {
//log the exception
}
Intent intent = new Intent(this, PreposisiRemoval.class);
String test = ((TextView)findViewById(R.id.textView7)).getText().toString();
String[] preposisi = {text}; "GET ERROR IN THIS LINE"
StringBuilder resultFilter = new StringBuilder();
Scanner fip1 = new Scanner(test);
while (fip1.hasNext()){
int flag = 1;
String s1 = fip1.next();
for (int i = 0;i<preposisi.length; i++){
if (s1.equals(preposisi[i])){
flag=0;
}
}
if(flag!=0){
System.out.println(s1);
resultFilter.append(s1+'\n');
}
Intent intent2 = getIntent();
String count = intent2.getStringExtra("result2");
intent.putExtra("resultFilter", resultFilter.toString());
intent.putExtra("count", count);
startActivity(intent);
}
}
}
我得到誤差在該行字符串preposisi = {}測試
其中你正在從bufferedreader轉換到字符串的行 –
你想在行'String [] preposisi = {text};'中做什麼? –