I have made reference from this question and achieved success in setting up encryption. I am trying to however utilize this encryption on a string of array to write into a file. This is how I am setting my method up but I end up writing only one of the string array into the file.
String[] str = new String ["X: Adam", "Y: Barry", "z: Oliver"];  
File file = new File(Path + "/EncryptedFile.txt);
Calling method to write the string array into the file: Crypto.WriteEncrypteFile(str, file);
The method
Public void WriteEncrypteFile(String[] str, File file) {
  try { 
    BufferedWriter w = new BufferedWriter(new FileWriter(file)); 
    byte[] tmptxt = Array.toString(str).getbytes(Charset.forName(" UTF-8 "));  
    byte[] encTxt = cipher.doFinal(tmptxt);
    w.write(string.valueOf(encTxt)); 
    w.flush();
    w.close(); 
  } catch (Exception e){
    e.printStackTrace();
  }    
My questions is how can I write an encrypted string from my array into the file. Any pointers?
 
     
     
     
    