1 2 Previous Next 23 Replies Latest reply on May 18, 2009 12:34 PM by JoachimSauer

    Opening a text file

    807588
      Hello,

      Does anyone know how to open a text file (.txt) in java? I dont want to read the data inside it, i want it to pop up on the screen somewhere.

      thanks
        • 1. Re: Opening a text file
          JoachimSauer
          Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
          • 2. Re: Opening a text file
            807588
            pop up in what fashion? My guess is that you're either going to have to open, read it, and then display it in a Swing component, or else display it in another (OS-specific?) text viewing app. Details are important here.
            • 3. Re: Opening a text file
              807588
              When i say pop up i mean display it like you would open a standard, for example word document. I dont want to display it in a GUI.
              I just want user of the application to open the file by clicking a button and read the text inside it. for example opening a user manual.
              I am using windows vista OS.

              Let me know if you want more details

              Thanks
              • 4. Re: Opening a text file
                796440
                learner1 wrote:
                When i say pop up i mean display it like you would open a standard, for example word document. I dont want to display it in a GUI.
                I just want user of the application to open the file by clicking a button and read the text inside it. for example opening a user manual.
                I am using windows vista OS.
                So, you want to use Java to, e.g., launch word and open a particular document in word?
                • 5. Re: Opening a text file
                  807588
                  JoachimSauer wrote:
                  Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
                  This link doesnt have what i want!!!!!!
                  Any other link apart from search engine? cos i have tried that already
                  • 6. Re: Opening a text file
                    796440
                    learner1 wrote:
                    JoachimSauer wrote:
                    Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
                    This link doesnt have what i want!!!!!!
                    Shouting will not encourage people to help you.
                    Any other link apart from search engine? cos i have tried that already
                    If you provide a sufficiently precise query, I strongly suspect google will be immensely helpful.
                    • 7. Re: Opening a text file
                      807588
                      ya, but not microsoft word. i want to display a .txt file or maybe a .pdf file if possible
                      • 8. Re: Opening a text file
                        796440
                        learner1 wrote:
                        ya, but not microsoft word. i want to display a .txt file or maybe a .pdf file if possible
                        You are REALLY not being clear.

                        Do you want the doc to be opened by its "default" application--e.g. Adobe for .pdf, Notepad for .txt, Word for .doc, etc.?

                        If not, then what are you trying to do?
                        • 9. Re: Opening a text file
                          807588
                          jverd wrote:
                          learner1 wrote:
                          JoachimSauer wrote:
                          Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
                          This link doesnt have what i want!!!!!!
                          Shouting will not encourage people to help you.
                          Any other link apart from search engine? cos i have tried that already
                          If you provide a sufficiently precise query, I strongly suspect google will be immensely helpful.
                          Shouting?????????

                          Who said i am shouting?
                          • 10. Re: Opening a text file
                            796440
                            learner1 wrote:
                            jverd wrote:
                            learner1 wrote:
                            JoachimSauer wrote:
                            Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
                            This link doesnt have what i want!!!!!!
                            Shouting will not encourage people to help you.
                            Any other link apart from search engine? cos i have tried that already
                            If you provide a sufficiently precise query, I strongly suspect google will be immensely helpful.
                            Shouting?????????

                            Who said i am shouting?
                            Multiple exclamation points is considered shoutng. Even one might be, for that matter.

                            Edited by: jverd on Apr 30, 2009 11:53 AM
                            • 11. Re: Opening a text file
                              JoachimSauer
                              learner1 wrote:
                              JoachimSauer wrote:
                              Sure: [here you go|http://java.sun.com/docs/books/tutorial/essential/io/].
                              This link doesnt have what i want!!!!!!
                              'And all those exclamation marks, you notice? Six? A sure sign of someone who wears his underpants on his head.'

                              ( Sorry, Mr. Pratchett, I had to take some liberty in quoting this ).

                              Maybe your lordship might be interested in [this class|http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html].
                              • 12. Re: Opening a text file
                                807588
                                jverd wrote:
                                learner1 wrote:
                                ya, but not microsoft word. i want to display a .txt file or maybe a .pdf file if possible
                                You are REALLY not being clear.

                                Do you want the doc to be opened by its "default" application--e.g. Adobe for .pdf, Notepad for .txt, Word for .doc, etc.?

                                If not, then what are you trying to do?
                                I have a .txt file saved in my folder where the java application is and i want to open it by clicking a button.

                                now this should REALLY be clear, hopefuly
                                • 13. Re: Opening a text file
                                  796440
                                  learner1 wrote:
                                  jverd wrote:
                                  learner1 wrote:
                                  ya, but not microsoft word. i want to display a .txt file or maybe a .pdf file if possible
                                  You are REALLY not being clear.

                                  Do you want the doc to be opened by its "default" application--e.g. Adobe for .pdf, Notepad for .txt, Word for .doc, etc.?

                                  If not, then what are you trying to do?
                                  I have a .txt file saved in my folder where the java application is and i want to open it by clicking a button.
                                  Define "open." Which application is supposed to display it? Previously you said something about not wanting a GUI, which suggests it won't be your Java program, unless maybe you mean you want to display its contents on the console.
                                  now this should REALLY be clear,
                                  Nope.
                                  • 14. Re: Opening a text file
                                    807588
                                    jverd wrote:
                                    learner1 wrote:
                                    jverd wrote:
                                    learner1 wrote:
                                    ya, but not microsoft word. i want to display a .txt file or maybe a .pdf file if possible
                                    You are REALLY not being clear.

                                    Do you want the doc to be opened by its "default" application--e.g. Adobe for .pdf, Notepad for .txt, Word for .doc, etc.?

                                    If not, then what are you trying to do?
                                    I have a .txt file saved in my folder where the java application is and i want to open it by clicking a button.
                                    Define "open." Which application is supposed to display it? Previously you said something about not wanting a GUI, which suggests it won't be your Java program, unless maybe you mean you want to display its contents on the console.
                                    now this should REALLY be clear,
                                    Nope.
                                    orite i get now, ur sick up in the head
                                    1 2 Previous Next