Results 1 to 4 of 4
  1. #1
    Lord ice is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Question Saving inforation from notepad

    Okay so for this assignment i have to save a piece of information from notpad to a varible in my program, but i have no idea how, i can only make it output to the screen. Could someone help me please?

  2. #2
    f1gh is offline Member
    Join Date
    Nov 2010
    Posts
    46
    Rep Power
    0

    Default

    please clarrify:
    do you mean input from a file that you created in notepad??? i know how to do this. you basically need to create a : (in examp i assume name of file is var.txt)

    Java Code:
    BufferedReader readVar = new BufferedReader(new FileReader("var.txt"));
    to read stuff from a file.

    or you mean open up notepad, writing something in notepad and get what you just wrote in notepad?? I don't know how you can do this part without first saving what you wrote in notepad to file and than reading file. Its probably impossible but if you had extensive knowledge of windows and what buffer/structure notepad is temporarily saving data in as you write but outside of that i have no clue how to do this without first having data saved to file.

  3. #3
    Lord ice is offline Member
    Join Date
    Dec 2010
    Posts
    5
    Rep Power
    0

    Default

    Well, i typeing something in notepad, and saved it. Now i want my program to be able to display it, on screen, and be able to save the first line of text in to a varible.

  4. #4
    f1gh is offline Member
    Join Date
    Nov 2010
    Posts
    46
    Rep Power
    0

    Default

    okay well i already gave you solution in my first post on how to do that ....

    Read up on BufferedReader (just do google search for it).

    basically if you look at code i gave you readVar is now an instance of BufferedReader. Once you have an instance/object of a class you have access to that class's public methods and variables. So now readVar can access method readLine() of BufferedReader which will allow you to read lines from file you created.

    But again you should read up on BufferedReader and FileReader to learn about their functionality and usage.

Similar Threads

  1. modules in notepad
    By joypik in forum New To Java
    Replies: 6
    Last Post: 11-22-2010, 06:47 PM
  2. Notepad program
    By sridevisala in forum Java Software
    Replies: 1
    Last Post: 04-26-2010, 10:56 AM
  3. problem with notepad
    By munish in forum Advanced Java
    Replies: 7
    Last Post: 08-30-2009, 12:53 PM
  4. NotePad
    By whosadork in forum New To Java
    Replies: 10
    Last Post: 10-03-2008, 08:44 PM
  5. Notepad or IDE?
    By Eranga in forum Other IDEs
    Replies: 30
    Last Post: 09-22-2008, 05:20 AM

Posting Permissions

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