I have a Java class with some code that will work based on the flag value, below my code that works as the flag value is 1
if(flag==1)
{
Log.d("Flag value", "flag= "+flag);
System.out.println("Read have "+read());
String tt=read();
s1=tt;
}
From this function above, the value in the variable "s1" is some string value returned by the read () function.
the output of this code returns twice the read () function, for example
s1 with "StringString"
Here is my read function code
public String read(){
try{
FileInputStream fin = openFileInput(file);
int c;
while( (c = fin.read()) != -1)
{
temp = temp + Character.toString((char)c);
}
}
catch(Exception e)
{
}
Log.d("INSIDE READ FUNC", "temp have "+temp);
return temp;
}
So far I have skipped this "System.out.println (" Read have "+ read ()); below the code
if(flag==1)
{
Log.d("Flag value", "flag= "+flag);
//System.out.println("Read have "+read());
String tt=read();
s1=tt;
}
And I got a great result, for example
s1 having "String"
Why does the code work like this? I called the read () function only once to save the "tt" variable.
And saving the tt variable to the s1 variable.
System.out.println( "Read have" + read()); , "tt" String read() "tt" String.
, String "tt" read() .
?