java - file exists but in toast it's empty -


the toast says file exists, after read response empty. can mistake?

thanks

filename = "locations.txt"; file file = new file(environment.getexternalstoragedirectory()             .getabsolutepath() + "/doma/" + filename);      string response = "";      if (file.exists()) {         toast.maketext(this, filename + " exists", toast.length_short).show();         bufferedreader br;          try {             br = new bufferedreader(new inputstreamreader(new fileinputstream(file), "cp1252"));             (string line; (line = br.readline()) != null; response += line + '\n') ;         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }         toast.maketext(this, "read:\n" + response, toast.length_short).show();     } else {         toast.maketext(this, "sorry, " + filename + " doesn't exist!!", toast.length_long)                 .show();     } 

if referring response set empty toast.maketext(this, "read:\n" + response, toast.length_short).show();

your toast must file , not filename .. value of filename?

file file = new file(environment.getexternalstoragedirectory()             .getabsolutepath() + "/doma/" + filename);      string response = "";      if (file.exists()) {         toast.maketext(this, filename + " exists", toast.length_short).show();         bufferedreader br;          try {             br = new bufferedreader(new inputstreamreader(new fileinputstream(file), "cp1252"));             (string line; (line = br.readline()) != null; response += line + '\n') ;         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }  toast.maketext(this, "read:\n" + response, toast.length_short).show();                 .show();     } else {      toast.maketext(this, "sorry, " + file + " doesn't exist!!", toast.length_long)     } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -