2 Replies Latest reply: Oct 10, 2009 2:47 PM by 3004 RSS

    write white space to file

    843789
      i want to write some character to file each character separate with a white space or tab this code below but it does not do what i want, the result file contain some square.
      how i solve this problem.
      import java.io.File;
      import java.io.FileWriter;
      import java.io.IOException;
      
      import java.util.Random;
      
      public class WriteWhiteSpace {
           public static void main(String args[]) throws IOException
           {
                File outputFile = new File("out.txt");
                FileWriter out = new FileWriter(outputFile);
                int ch  = 0;
                Random ran = new Random();
                while( ch != 120 )
                {
                     ch = 70 + ran.nextInt(122-70);
                     out.write(ch);
                     out.write(32); // 32 is ascii key
                     //out.write(" "); 
                }
                out.close();
                
                     }
          }
      Edited by: phamthao on Oct 10, 2009 12:37 PM

      Edited by: phamthao on Oct 10, 2009 12:38 PM