title: Base64.Decoder returning foreign characters
body: <p>I am building a small application to turn the text in a text file to Base64 then back to normal. The decoded text always returns some Chinese characters in the beginning of the first line. </p>
  
  <pre><code>public EncryptionEngine(File appFile){
      this.appFile= appFile;
  }
  
  
  public void encrypt(){
  
      try {
          byte[] fileText = Files.readAllBytes(appFile.toPath());// get file text as bytes
  
          Base64.Encoder encoder = Base64.getEncoder();
          PrintWriter writer = new PrintWriter(appFile);
  
          writer.print("");//erase old, readable text
          writer.print(encoder.encodeToString(fileText));// insert encoded text
          writer.close();
  
  
      } catch (IOException e) {
  
          e.printStackTrace();
      }
  
  }
  
  public void deycrpt(){
  
      try {
          byte[] fileText = Files.readAllBytes(appFile.toPath());
  
          String s = new String (fileText, StandardCharsets.UTF_8);//String s = new String (fileText);
  
  
          Base64.Decoder decoder = Base64.getDecoder();
          byte[] decodedByteArray = decoder.decode(s);
  
          PrintWriter writer = new PrintWriter(appFile);
          writer.print("");
          writer.print(new String (decodedByteArray,StandardCharsets.UTF_8)); //writer.print(new String (decodedByteArray));
          writer.close();
  
  
      } catch (IOException e) {
  
          e.printStackTrace();
      }
  
  
  
  }
  </code></pre>
  
  <p><strong>Text FileBefore before encrypt():</strong></p>
  
  <p>cheese</p>
  
  <p>tomatoes</p>
  
  <p>potatoes</p>
  
  <p>hams</p>
  
  <p>yams</p>
  
  <p><strong>Text File after encrypt()</strong> 
  //5jAGgAZQBlAHMAZQANAAoAdABvAG0AYQB0AG8AZQBzAA0ACgBwAG8AdABhAHQAbwBlAHMADQAKAGgAYQBtAHMADQAKAHkAYQBtAHMA</p>
  
  <p><strong>Text File After decrypt</strong></p>
  
  <p>뿯붿cheese</p>
  
  <p>tomatoes</p>
  
  <p>potatoes</p>
  
  <p>hams</p>
  
  <p>yams</p>
  
  <p><a href="https://i.stack.imgur.com/enuXu.jpg" rel="nofollow noreferrer">Before encrypt() :</a></p>
  
  <p><a href="https://i.stack.imgur.com/c6gHV.jpg" rel="nofollow noreferrer">After decrypt() :</a></p>