title: Reading an XML File using FileInputStream (for Java)?
body: <p>For my project I have to serialize and deserialize a random tree using Java and XStream.  My teacher made the Tree/RandomTree algorithms, so I don't have to worry about that.  What I don't know how to do is this:  I am using FileInputStream to read/write the xml file that I serialized and deserialized, but when I deserialize, I do not know the method used to read the file.  After I read the file I should be able to convert it from XML and then print it out as a string.  Here's what I have so far.  (I imported everything correctly, just didn't add it to my code segment).</p>
  <pre><code>FileInputStream fin;        
      
  try
  {
      // Open an input stream
      fin = new FileInputStream (&quot;/Users/Pat/programs/randomtree.xml&quot;);
  
      //I don't know what to put below this, to read FileInpuStream object fin
  
      String dexml = (String)xstream.fromXML(fin);
  
      System.out.println(dexml);
          
      // Close our input stream
      fin.close();    
          
      
      System.out.println(dexml);
          
      // Close our input stream
      fin.close();        
  }
  // Catches any error conditions
  catch (IOException e)
  {
      System.err.println (&quot;Unable to read from file&quot;);
      System.exit(-1);
  }
  
      
      
  </code></pre>
  <hr />
  <p><strong>Edit:</strong>  I figured it out; I don't think I have to print it as a string, I just needed to make a benchmarking framework to time it and such, but thanks again!</p>