Results 1 to 6 of 6

Thread: Open File

  1. #1
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default Open File

    Hi all

    How can i open a .txt file through menu item.Plz help me

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Add a listener to the menu item and when the item is selected, the listener will be called and there you can open the file.

  3. #3
    JavaLerner is offline Member
    Join Date
    Jul 2008
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Add a listener to the menu item and when the item is selected, the listener will be called and there you can open the file.
    Sir can you give me some code of this..

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    You can probably find all you want by using a search.
    Look that the API doc for the type of menu item you are using, find the addListener methods that are defined for that class and do a search for those methods. That could find you examples of how to use them.
    Same for the other parts of the problem.

  5. #5
    Join Date
    Jul 2008
    Posts
    33
    Rep Power
    0

    Default

    You can use the File class to open a file and the scanner class to read it. It isn't that difficult to write a simple text reader.
    :DMy community with sourcode and examples :D
    Java remote image server/client working proof of concept: uitstekendeaccu.nl/tmp/

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default oversimplified place to start

    Quote Originally Posted by Engineeringserver.com View Post
    You can use the File class to open a file and the scanner class to read it. It isn't that difficult to write a simple text reader.
    Java Learner,

    These other two posters are heavily experienced, I did not try to get this to compile: They can help you with this:

    Java Code:
    import java.io.File;// 
    import java.io.PrintWriter://
    public class FileDemo
    {
        public static void main(String[] args)
        {
            // Simple
            for(int i= 0;i < args.length;i++)
            {
                File nextFile = new File(args[i]);
                if(nextFile.exists())
                {
                    ;// That file already exists.
                }
                else
                {
                    PrintWriter printWrite
                    =
                    new PrintWriter(nextFile);
            }
        }
    }
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Similar Threads

  1. open a pdf file in linux
    By aparna in forum Advanced Java
    Replies: 5
    Last Post: 06-08-2010, 12:51 PM
  2. how to open a file through URL
    By katie in forum New To Java
    Replies: 3
    Last Post: 07-13-2008, 02:53 AM
  3. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 09:57 AM
  4. Is it possible to open a txt file?
    By jason27131 in forum New To Java
    Replies: 20
    Last Post: 08-07-2007, 01:24 AM
  5. open lazlo
    By Peter in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 06:22 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
  •