title: Is there a way to format decimal point numbers while using PrintWriter, without using "Format" function in Java?
body: <p>I am writing out data to a file for my Java simulation. My code looks like this: </p>
  
  <pre><code>try (PrintWriter out = new PrintWriter(new FileWriter("data/test.dat", true));)
        {
          out.print(DecimalPointData);
          out.print("\t");
          out.print(OtherData);
          out.print("\n");            
          } catch (IOException {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>This prints out data like this:</p>
  
  <pre><code>  -1.0749999955296516   0.0
    -1.0919999964535236   0.0
    -1.0749999955296516   0.0
    -0.5339999794960022   0.0
  </code></pre>
  
  <p>I am aware of the fact that data in java can be formatted using .format, i.e., if I can just say</p>
  
  <pre><code>out.format("%.3f%n",DecimalPointData); 
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>out.print(DecimalPointData);
  </code></pre>
  
  <p>But I do not want to use this in my code, because when I write to the file, the columns look disoriented, my file data looks ends up looking like this: </p>
  
  <pre><code>-1.075
        0.0
  -1.092
        0.0
  -1.075
        0.0
  </code></pre>
  
  <p>Is there anything else I need to know while formatting? or Is there another way to format decimal point numbers with the use of "Format" function in java? </p>