title: Java: Blank File on writing
body: <p>I am trying to write to a file in Java using the following function:</p>
  
  <pre><code>public void writeTextFile(String filename, double s){
    FileWriter output=null;
    try{
      output= new FileWriter(filename);
      BufferedWriter writer=new BufferedWriter(output);
      String ss = String.valueOf(s);
      writer.write(ss);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (output != null) {
        try {
          output.flush();
          output.close();
        } catch (IOException e) {
  
        }
      }
    }
  }
  </code></pre>
  
  <p>I also tried using:</p>
  
  <pre><code>FileOutputStream out;
  PrintStream prt;
  try{
    out= new FileOutputStream("result");
    prt=new PrintStream(out);
    prt.println(value);
    prt.flush();
    prt.close();
  }
  catch(Exception e){
    System.out.println("File write error");}
  </code></pre>
  
  <p>But i end up with a blank output file with both the methods. Need help!!:(</p>