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: PRINTWRITER Class

  1. #1

    Default PRINTWRITER Class

    I have a few questions relating to I/o files.

    1.) Is FileReader class the same as File Class. In my book it uses File class to read data from a file, but one of the members here used FileReader so I was wanting to know if it's identical function or not.

    2.) When creating an output file, I will use
    PrintWriter outputfile("hello.txt")
    i just read a new topic of " appending data to a file," meaning if I want to preserve the old file I would have to use this. From my understanding all this does is prevents the old data from being deleted. Now, in my code if I type
    ( "hello.txt",true)
    this would preserve the old data?

    One more thing, what does this even do [CODE]FileWriter file=new FileWriter; PRINTWRITER output=new PrintWriter(file) [CODE/]


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: PRINTWRITER Class

    In my book it uses File class to read data from a file
    Is that class in the java SE java.io package? That class has no methods for reading data from a file.

    Is FileReader class the same as File Class.
    Read the API doc to see what each class's methods do.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] PrintWriter out problem
    By Randor in forum Java Networking
    Replies: 1
    Last Post: November 27th, 2012, 09:55 AM
  2. PrintWriter: passing File reference vs String
    By kahwa in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 12th, 2012, 12:56 AM
  3. Null Exception Error & Help with PrintWriter
    By willo in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 29th, 2011, 09:08 AM
  4. [SOLVED] Printwriter class: displaying File contents to screen with included formatting?
    By mwebb in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: November 25th, 2011, 11:38 AM
  5. Problems with PrintWriter
    By dbridle in forum What's Wrong With My Code?
    Replies: 10
    Last Post: October 29th, 2010, 03:51 PM