我有一个
的应用程序但是当该文件以该名称保存时,fileInputStream
不响应该名称。
我该怎么办?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_load_food);
bundle = getIntent().getExtras();
Toolbar toolbar=(Toolbar)findViewById(R.id.food_lood_toolbar);
setSupportActionBar(toolbar);
file=bundle.getString("diname");
getSupportActionBar().setTitle(file);
String q=”123”;
if (bundle.getString("activity").equals(q)) {
String e1=editText1.getText().toString() +"/";
fileOutputStream=openFileOutput(file,Context.MODE_PRIVATE);
fileOutputStream.write(e1.getBytes());
}
String t="321";
if (bundle.getString("activity").equals(t)){
try {
fileInputStream= openFileInput(file);
int x;
StringBuffer y = new StringBuffer();
while((x=fileInputStream.read())!=-1){
y.append((char)x);
}
String c=y.toString();
txt=c.split("/");
editText1.setText(txt[0]);
} catch (FileNotFoundException e) {
Toast.makeText(getBaseContext(),"file not found",Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(getBaseContext(),"io",Toast.LENGTH_LONG).show();
e.printStackTrace();
}
finally {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}