title: java.io.File getting extra char while writing into file
body: <p>Why I am getting extra char while writing into file for the following code? If I am using <code>writeBytes(String)</code> than the below code is working file. Then what is the problem with <code>dos.writeChars()</code> method?</p>
  
  <pre><code>File fileObj = new File("student.txt");
  
  try {
  
    // writing into file
    FileOutputStream fos = new FileOutputStream(fileObj);
    String msg = "This is student file";
  
    DataOutputStream dos = new DataOutputStream(fos);
    dos.writeChars(msg);
  
    //reading from file
    FileInputStream fis = new FileInputStream(fileObj);
    DataInputStream dis = new DataInputStream(fis);
  
    System.out.println(dis.readLine());
  
    for (int i = 0; ((i = dis.read()) != -1); i++) {
      System.out.println(i);
    }
  
    fos.close();
    dos.close();
  
  } catch (FileNotFoundException e) {
    System.err.println("File not found!");
  } catch (IOException e) {
    e.printStackTrace();
  }
  </code></pre>