String datas = "volume of";
writesettings(datas);
String data = readsettings();
String data2 = "volume of";
if (data == datas) {
System.out.println("success");
}
System.out.println(data);
System.out.println(data.length());
System.out.println(datas.length());
}
// Write Settings
public void writesettings(String data){
try {
FileOutputStream fOut = openFileOutput("settings.dat", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(data);
osw.flush();
osw.close();
}catch(Exception e){
e.printStackTrace(System.err);
}
}
public String readsettings(){
try {
FileInputStream fIn = openFileInput("settings.dat");
InputStreamReader isr = new InputStreamReader(fIn);
char[] inputBuffer = new char[9];
isr.read(inputBuffer);
String readString = new String(inputBuffer);
datax = readString;
isr.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return datax;
}
答案 0 :(得分:2)
equals()
。System.out.println
无法在Android上运行。使用Log
。