I want to read a string from a file which is in the asset folder. I can read wihtout problem but I have a strange problem when I try to manipulate these string.
Content of my data file
[001]
[SCA] 23
[NBT] 2
[END]
public static String readLevelFromFileAsset(String filename, Context ctx, String levelID)
{
String Content = null;
try {
AssetManager am = ctx.getAssets();
InputStream is = am.open(filename);
if ( is != null )
{
InputStreamReader inputStreamReader = new InputStreamReader(is);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String receiveString = "";
StringBuilder stringBuilder = new StringBuilder();
while ((receiveString = bufferedReader.readLine()) != null )
{
Log.d(TAG, receiveString + " : " + receiveString.length());
byte[] bytes = EncodingUtils.getAsciiBytes(receiveString);
for(int i = 0; i < bytes.length; i++)
{
Log.d(TAG,String.valueOf(bytes[i]));
}
if(receiveString == "[001]")
{
Log.d(TAG, "Hello");
stringBuilder.append(receiveString);
}
}
is.close();
Content = stringBuilder.toString();
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
finally
{
Log.d(TAG, Content);
}
return Content;
}
Ce content of the logs:
[001] : 5
91
48
48
49
93
My question is : WHY the word 'Hello' is not written in the log ? it seems that in the 'IF' the receivestring is unknown !