If I am using the File object to read a file and PrintWriter object to write to a separate file, can I use them under one method. Or is the File one method and the PrintWriter another method?
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.
If I am using the File object to read a file and PrintWriter object to write to a separate file, can I use them under one method. Or is the File one method and the PrintWriter another method?
I don't think I understand your question: they are not methods, they are classes.Or is the File one method and the PrintWriter another method?
File (Java Platform SE 7 )
PrintWriter (Java Platform SE 7 )
Ok,
So I want to create a method to read data from a file. I also want to print data to a separate file. So, can I create one method to do both tasks using the File class and the PrintWriter class? I hope that makes more sense.
thank you
Your one method can call methods in other classes to do the reading and writing.can I create one method to do both tasks using the File class and the PrintWriter class?
BTW The File class does not have methods for reading the contents of a file.
The Scanner class has several methods for reading the contents of a file.
If you don't understand my answer, don't ignore it, ask a question.
Yes, you are right the File class will open the file. Got it. Thanks for the insight. I think I got it now.
thanks again