Writing to file

From: undbund (undbund_at_yahoo.com)
Date: 05/31/04


Date: 30 May 2004 19:00:17 -0700

Hi, I have been following java tutorial provided by Sun. Here is an
example of code from that tutorial.

import java.io.*;
public class formatedData {
    public static void main( String[] args ) throws IOException{
         
         DataOutputStream out = new DataOutputStream(new
                                   FileOutputStream("d://data.txt"));
         double[] prices = { 19.99, 9.99, 15.99, 3.99, 4.99 };
         String[] descs = { "Java T-shirt",
                           "Java Mug",
                           "Duke Juggling Dolls",
                           "Java Pin",
                           "Java Key Chain" };
         for (int i = 0; i < prices.length; i ++) {
              out.writeChars(descs[i]);
              out.writeChar('\t');
              out.writeDouble(prices[i]);
              out.writeChar('\n');
              
        }
        out.close();
        System.out.print("Program finished...");
    }
       
}

The output in the text file should be:

Java T-shirt 19.99
Java Mug 9.99

etc...

But I get:
J a v a T - s h i r t @3ýp£× J a v a M u g @#úáG®

How do i solve this probelem?

thanx for all your help
undbund



Relevant Pages