ciao .
Ho trovato questo esempio di codice su google:
io vorrei recuperare direttamente la stringa unzippata(del primo e unico file che avro') e senza salvare il file e ho fatto una prova con lo StringBuffer e l'append utilizzando il costruttore della stringa che prende byte e utf-8.codice:try { byte[] data = new byte[1000]; int byteRead; BufferedOutputStream bout = null; ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new ByteArrayInputStream(Data))); ZipEntry entry; StringBuffer buff = new StringBuffer(); while((entry = zin.getNextEntry()) != null) { byteRead=0; data = new byte[1000]; String strPath = m_context.getApplicationContext().getFilesDir() + "/dbs/"+entry.getName(); bout = new BufferedOutputStream(new FileOutputStream(strPath,true),1000); while ((byteRead = zin.read(data,0,1000)) != -1) { buff.append(new String((byte[])data, "UTF-8")); bout.write(data,0,byteRead); } String str = buff.toString(); bout.flush(); bout.close(); } m_finish.finish(); } catch(Exception e) { e.printStackTrace(); }
Il problema è che la stringa risultante non è completa, dove sbaglio?
ho usato uno StringBuffer perchè ho letto che è thread safe invece dello StringBuilder ma il problema non è li'.
grazie.

Rispondi quotando