Can someone tell me why my data is not printing to my file. It will create the text file but it will not write to it.

Here is a snippett:

 out = new PrintWriter("completeAuto.txt");

            while ((car = br.readLine()) != null && (van = br1.readLine())!=null && (truck = br2.readLine()) != null) 
            {
               out.print (car );                    
               out.print(truck); 
            } 

Thanks

The PrintWriter(String s) constructor does not contain automatic flushing to the writer. You need to use println statements to do this rather than print statements. Or immediately after your while loop call out.flush().
Also, I think maybe you need or statements in your while loop as opposed to and statements, but that may depend on what you are actually trying to achieve.

you maybe need to close the file after editing..

Small example how to write into file

import java.io.*;
class FileWrite 
{
   public static void main(String args[])
  {
      try{
    // Create file 
    FileWriter fstream = new FileWriter("out.txt");
        BufferedWriter out = new BufferedWriter(fstream);
    out.write("Hello Java");
    //Close the output stream
    out.close();
    }catch (Exception e){//Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.