title: Using DataOutputStream to save a file, the how to out write the list<String>
body: <p>I want to use DataOutputStream to get a file named"saved.txt". here are the codes:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.DataOutputStream;
  import java.util.List;
  import java.util.ArrayList;
  import java.io.FileOutputStream;
  
  
  
  public class ObjectOutputStreamTest {
  public static void main(String[] args){
      int number1=5;
      double number2=10.3;
      String string="a string";
      List&lt;String&gt; list=new ArrayList&lt;&gt;();
      list.add("a");
      list.add("a");
  
      try{
          DataOutputStream out= new DataOutputStream(new       FileOutputStream("saved.txt"));
  
          out.writeInt(number1);
          out.writeDouble(number2);
          out.writeBytes(string);
          out.write(list);
      } catch( IOException e) {
          e.printStackTrace();
      }
      }
  
  
      }
  </code></pre>
  
  <p>But there is error at <code>out.write(list);</code>, the error is:
  The method write(int) in the type DataOutputStream is not applicable for the arguments (List). So how to correct this error? Thank you for any suggestion and answers.</p>