Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Reading file

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Reading file

    I am using the following code to read a file. I read the file, do some modifications on it and save it, and I see that my changes have been applied to the file, but when I open the file again in JEditorPane I can't see what I have added to it. the changes that I make to the file are just adding some lines to the end of it.


    public void actionPerformed(ActionEvent e) {
     
        	JEditorPane note = new JEditorPane();
            //Handle open button action.
           if (e.getActionCommand().equals("New File")) {
                int returnVal = fc.showOpenDialog(UpLoadListener.this);
     
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    file = fc.getSelectedFile();
     
                    try {
    					Content =  file.toURI().toURL();
    						if (Content != null) {
    								try {
    									 note.setContentType("text/html");
    									 note.setPage(Content);
     
    									} catch (IOException e1) {
    									System.err.println("Attempted to read a bad URL: " + Content);
    								}
    						} else {
    							System.err.println("Couldn't find file");
    						}
     
    				} 
                   catch (MalformedURLException e2) {
    					// TODO Auto-generated catch block
    					e2.printStackTrace();
    				}
                }
            }
        }


  2. #2
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: Reading fiel

    Do you mean that nothing is wrong with my code?

Similar Threads

  1. Anyone Help me in XML file Reading??????????
    By goplrao in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: May 2nd, 2010, 11:04 AM
  2. [SOLVED] reading only certain lines from a .txt file
    By straw in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: March 7th, 2010, 06:49 PM
  3. Reading from RSS server
    By Tisofa in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: August 18th, 2009, 04:04 AM
  4. reading a sentence
    By lotus in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: July 20th, 2009, 08:29 AM
  5. [SOLVED] Problem in reading a file from java class
    By aznprdgy in forum File I/O & Other I/O Streams
    Replies: 11
    Last Post: March 23rd, 2009, 09:31 AM