3 Replies Latest reply: May 6, 2009 7:46 AM by 807588 RSS

    How to write an interger value in a text file using java

    807588
      Hai toall,
      Can any one please tell me how to an interger value in a textfile. I could write a string into a file. But i am unable to write an integer value.
      i wrote like this in my program.

      public void writeToFile(int number) {
      int no;
      try {
      String f = "RecordCount.txt";
      FileOutputStream fop = new FileOutputStream(f);
      no=number;          
      fop.write(no);
           fop.flush();
           fop.close();
           System.out.println("The data has been written");

           } catch (Exception e) {
           e.printStackTrace();
           }

      }
      it didnt show any error. But interger value coudnt write into a file.
      Any one please help me out from this.
      Thanks in advance.