public void openOutFileInAppFilesDir(File pFile,String pFileOut){
  FileOutputStream fos=null;
  try {
    fos=new FileOutputStream(pFile);
  }
 catch (  FileNotFoundException e1) {
    failStr("Error when opening file " + e1);
    return;
  }
  try {
    fos.write(pFileOut.getBytes());
    fos.close();
  }
 catch (  FileNotFoundException e) {
    failStr(e.getMessage());
  }
catch (  IOException e) {
    failStr(e.getMessage());
  }
  int count=pFileOut.getBytes().length;
  byte[] buffer=new byte[count];
  try {
    FileInputStream fis=new FileInputStream(pFile);
    fis.read(buffer,0,count);
    fis.close();
  }
 catch (  FileNotFoundException e) {
    failStr("Failed when verifing output opening file " + e.getMessage());
  }
catch (  IOException e) {
    failStr("Failed when verifying output, reading from written file " + e);
  }
  String str=new String(buffer);
  assertEquals(str,pFileOut);
}

public void openOutFileInAppFilesDir ( File pFile , String pFileOut ) { FileOutputStream fos = null ; try { fos = new FileOutputStream ( pFile ) ; } catch ( FileNotFoundException e1 ) { failStr ( "Error when opening file " + e1 ) ; return ; } try { fos . write ( pFileOut . getBytes ( ) ) ; fos . close ( ) ; } catch ( FileNotFoundException e ) { failStr ( e . getMessage ( ) ) ; } catch ( IOException e ) { failStr ( e . getMessage ( ) ) ; } int count = pFileOut . getBytes ( ) . length ; byte [ ] buffer = new byte [ count ] ; try { FileInputStream fis = new FileInputStream ( pFile ) ; fis . read ( buffer , 0 , count ) ; fis . close ( ) ; } catch ( FileNotFoundException e ) { failStr ( "Failed when verifing output opening file " + e . getMessage ( ) ) ; } catch ( IOException e ) { failStr ( "Failed when verifying output, reading from written file " + e ) ; } String str = new String ( buffer ) ; assertEquals ( str , pFileOut ) ; }
this method opens an output file writes to it , opens the same file as an input stream , reads the contents and verifies the data that was written earlier can be read
