private byte [ ] getByteArrayFromFile ( final String file ) throws UnsupportedEncodingException { String ret = "" ; File fl = new File ( context . getFilesDir ( ) , file ) ; if ( fl . exists ( ) ) { try { FileInputStream fin = new FileInputStream ( fl ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ( int ) fl . length ( ) ) ; copyStream ( fin , baos ) ; return baos . toByteArray ( ) ; } catch ( IOException e ) { Log . e ( LogPersister . LOG_TAG_NAME , "problem reading file " + fl . toString ( ) , e ) ; } } return ret . getBytes ( "UTF-8" ) ; }
public for testing only