Results 1 to 2 of 2
  1. #1
    eponcedeleon is offline Member
    Join Date
    Feb 2010
    Rep Power

    Default writing to an opened file..

    I need to open a file, get before the end of the file "\n" and write to the file... i am trying to do this this way...however i cant find how to write to the file.

    Java Code:
    FileInputStream fstream = new FileInputStream("textfile.txt");
     // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    //Read File Line By Line
    while ((strLine = br.readLine()) == null)   {
     // write to file
    //Close the input stream

  2. #2
    FON is offline Senior Member
    Join Date
    Dec 2009
    Belgrade, Serbia
    Rep Power


    Java Code: fileName, boolean append) throws IOException

    public FileWriter(String fileName, boolean append) throws IOException

    Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.

    fileName - String The system-dependent filename.
    append - boolean if true, then data will be written to the end of the file rather than the beginning.
    IOException - if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

Similar Threads

  1. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  2. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  3. Replies: 9
    Last Post: 07-10-2008, 04:52 PM
  4. Deleting a File that is opened
    By ravian in forum Advanced Java
    Replies: 6
    Last Post: 01-30-2008, 02:05 PM
  5. Reading an already opened file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-25-2008, 06:50 PM

Posting Permissions

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