Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Need help urgently.

  1. #1
    amaravarman is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Exclamation Need help

    Hi guys,
    I am learning java for few days and i have 2 doubts.

    1. I have created a array of 6:3 size. i want to store the array data into a .txt file for further use
    Can any one explain me how to do it?
    If possible with a simple example.

    2. How can i read the Same above file and write the stored integer values back to the array with 6:3 size.


    Thanks in advance.......
    Last edited by amaravarman; 11-05-2011 at 09:14 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help urgently.

    Stating that your post is "urgent" suggests that you feel that it is more important than all of the other questions in this forum, which just isn't true. Please edit your post and get rid of all references to "urgent" in your post above, and I'll help you as best I can.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help urgently.

    OK, I guess it's not all that urgent.

    Much luck.

  4. #4
    amaravarman is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: Need help urgently.

    i have edited my post Mr.Fubarable

    can u post the solution for my questions asap.

    thanks in advance.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,405
    Rep Power
    20

    Default Re: Need help urgently.

    Quote Originally Posted by Fubarable View Post
    OK, I guess it's not all that urgent.
    And here I left my dinner and came running ... (huff, huff, pant, pant)
    Cosmos likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help

    Quote Originally Posted by amaravarman View Post
    1. I have created a array of 6:3 size. i want to store the array data into a .txt file for further use
    Can any one explain me how to do it?
    I would use a PrintWriter class for writing characters to a File. The logic in pseudo-code could be:

    Java Code:
    create PrintWriter object with file name to write to
    for loop going from 0 to less than number of rows in array
      for loop going from 0 to less than number of columns in array
        call PrintWriter object's print() method, passing in the array item for this row and column
            if passing in an int, will want to use String.valueOf(myInt) to convert int to a String first
        call PrintWriter object's print(" ") to add a space between Strings
      end of for loop through columns
      call PrintWriter object's println() method to create a new line
    end for loop through rows
    flush PrintWriter object
    close PrintWriter object

    2. How can i read the Same above file and write the stored integer values back to the array with 6:3 size.
    A Scanner object would work nicely using nested for loops similar to that which I describe above.

  7. #7
    Cosmos is offline Member
    Join Date
    Jul 2011
    Location
    New Delhi,India
    Posts
    56
    Rep Power
    0

    Default Re: Need help urgently.

    you can use FileInputStream and FileOutputStream for your query....

Similar Threads

  1. help needed urgently
    By amarchandar in forum New To Java
    Replies: 1
    Last Post: 03-04-2009, 10:00 AM
  2. JSP (urgently)
    By G.Ajay Kumar in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-19-2009, 05:43 AM
  3. Help!urgently please
    By kevN in forum AWT / Swing
    Replies: 10
    Last Post: 01-09-2009, 05:37 PM
  4. Help needed, urgently!
    By Emfy in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 03:06 PM
  5. please help urgently
    By ananas7777 in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 02:48 AM

Tags for this Thread

Posting Permissions

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