append issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • momotaro
    Contributor
    • Sep 2006
    • 357

    append issue

    I've created this method to append strings but it throws
    an exception when I try to use it:

    fdf.append(orm) ;

    orm is a string.

    Code:
    public void append(String text)
    	{
    		
    		try{
    			fstream = new FileWriter(file);
    			BufferedWriter file = new BufferedWriter(fstream);
    			file.append(text);
    			file.close();
    		}
    		catch (Exception e) {
    			System.err.println("Error: can't append");
    		}
    	}
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Do you have the stack trace of the exception?

    I think your constructor for file stream should have one more argument.

    Code:
    fstream = new FileWriter(file,true); --> True is for append
    Regards
    Dheeraj Joshi

    Comment

    Working...