Question : Writing into text file

How do I write all this text into a text file where it systematically aligned like how it aligns in command line. The codes are below.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
System.out.println("Name:\t\t" +splitString[0]);
						System.out.println("Address:\t" +splitString[3]);
						System.out.println("Contact:\t" +splitString[4]);
						System.out.println("Delivery date: " +inputDate);
	    				System.out.println("Delivery time: " +timing);
	    				System.out.println("");
				    	System.out.println("Your Order\n==========\n");
				    	for(int r=1; r<7; r++){
				    		if(store_order[r] != null)
				    		System.out.println(store_order[r]);
				    	}
				    	System.out.println("\n");
				    	System.out.println("Total number of cakes ordered: $" +total_qty);
				    	System.out.println("\nTotal price: " +compute_total+ "\n");
				    	
				    	if(store_order[6] != null)
				    		System.out.println(" *Remember to keep Durian Dream in the freezer and consume within 3 days.");
				    		
				    	if(compute_total < 50.00)
				    		System.out.println("As the total price of your order is less than $50.00, you will need to pay an additional 7.00 for delivery once you confirm. ");

Answer : Writing into text file

hi moombaz ,

we can write a text into a simple text file using java by the help of java.io.* package and its methods.
we use write() method of BufferedWriter class to get the file written.

here is a small example to make things clear..hope this will give you idea.

import java.io.*;

public class WriteTextFileExample{
    public static void main(String[] args)throws IOException{
    Writer output = null;
    String text = "Rajesh Kumar";
    File file = new File("write.txt");
    output = new BufferedWriter(new FileWriter(file));
    output.write(text);
    output.close();
    System.out.println("Your file has been written");        
    }
}
Random Solutions  
 
programming4us programming4us