Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    56
    Rep Power
    0

    Cool How to write integers into file?

    I want to write integers (p.e a telephone number or ID) into a file. But
    the method write() of FileWriter seems to support only char, not int.
    What am I supposed to do?
    Thanks.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Actually write() method deals with Strings, or char buffer(actually array is the correct word in Java). So what you've to do is, convert the int into string and write it to the file. When you read and want to deal with them as numbers(int) convert back to int. That's all.

Similar Threads

  1. Reading Integers from a text file
    By tress in forum New To Java
    Replies: 6
    Last Post: 02-26-2011, 05:45 PM
  2. Write to a file in a jar
    By Ms.Ranjan in forum New To Java
    Replies: 4
    Last Post: 06-12-2009, 09:27 PM
  3. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  4. [SOLVED] File Write in File
    By Eku in forum New To Java
    Replies: 4
    Last Post: 10-27-2008, 04:01 AM
  5. Write to file
    By esadeghi in forum Advanced Java
    Replies: 1
    Last Post: 05-21-2008, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •