java - Android read large files crashing app -


hello can see below m trying make (android) app check md5 hash of file code works small files can me?

final textview informations = (textview) findviewbyid(r.id.informations);             final edittext input = (edittext) findviewbyid(r.id.tocrack);             string filepath = data.getdatastring();             string rawtext;             string hash;             stringbuilder text = new stringbuilder();             filepath = filepath.split("//")[1];             file file = new file(filepath);             toast.maketext(getapplicationcontext(),"loading: "+filepath,toast.length_long).show();             fileinputstream fis = null;             bufferedinputstream bis = null;             datainputstream dis = null;             try{                 fis = new fileinputstream(file);                 bis = new bufferedinputstream(fis);                 dis = new datainputstream(bis);                 while (dis.available() != 0){                     text.append(dis.readline()+"\n");                 }             }             catch (ioexception e){                 e.printstacktrace();             }             {                 try{                     fis.close();                     bis.close();                     dis.close();                 }                 catch (ioexception ex){                     ex.printstacktrace();                 }             }             rawtext = text.tostring().substring(0, text.length()-1);             hash = new md5(rawtext).hexdigest();             if (hash.equals(input.gettext().tostring())){                 informations.settext("hash correspond file!");             }             else{                 informations.settext("file hash= "+hash+"\nhashes not correspond :(");             }             toast.maketext(getapplicationcontext(),"copied file hash clipboard.",toast.length_long).show(); 

mobile device environments such android have limitations w.r.t amount of memory can consumed application. hence, reading large files in-memory data store done in code (using stringbuffer) going throw outofmemory error.

take @ this question know how can overcome problem.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -