Results 1 to 4 of 4
Like Tree4Likes
  • 4 Post By JosAH

Thread: PrintWriter completely deletes tex inside file

  1. #1
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default PrintWriter completely deletes tex inside file

    I have a text file "info".
    I want to add some text to "info", also keeping previous notes undeleted.
    How to do it?
    No java.doc please.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: PrintWriter completely deletes tex inside file

    Create a FileOutputStream instance specifying the file name and the append option.
    Use the FOS instance as an argument when creating your PrintWriter instance.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: PrintWriter completely deletes tex inside file

    Quote Originally Posted by asdfg View Post
    No java.doc please.
    You don't realize how silly that sounds, do you? The API documentation is the definitive answer to any question you might have about the core classes and their methods. Refusing to read it is just plain silly.

    kind regards,

    Jos
    Tolls, CorJava, SurfMan and 1 others like this.
    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: PrintWriter completely deletes tex inside file

    Learn to browse the Javadoc. We are not your personal Java Siri or Cortana.

    Read this: FileOutputStream (Java Platform SE 8 )
    Then you see this: public FileOutputStream(File file, boolean append)
    And you learn this: append - if true, then bytes will be written to the end of the file rather than the beginning
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

Similar Threads

  1. Write command deletes everything in csv file
    By Hyeri in forum New To Java
    Replies: 2
    Last Post: 12-06-2016, 11:07 AM
  2. File Out - PrintWriter
    By javaStooge in forum New To Java
    Replies: 19
    Last Post: 04-29-2014, 06:56 PM
  3. Replies: 1
    Last Post: 04-11-2014, 02:40 AM
  4. File IO (PrintWriter and Methods)
    By rgru25 in forum New To Java
    Replies: 8
    Last Post: 03-14-2013, 02:38 PM
  5. How to create a completely new file?
    By CORNandTOOTHPICK in forum New To Java
    Replies: 4
    Last Post: 01-27-2013, 11:24 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
  •