Tags:
tag this topic
create new tag
view all tags
---+Hint: working with files for lab 08 ---++Reading a file There are plenty of class examples of this. Be sure to use a !FileReader (as covered in class as opposed to any other way to read from a text file). ---++Writing to a file There are a number of class examples for this. Remember to instantiate a !PrintWriter using a !FileOutputStream. Then it is just like using System.out ---++Appending to a file * To add text to the end of a file, when creating a !FileOutputStream, add true to the arguments to the new command (as done in class example). * If the previous file does not end on a blank line (which is what is true for this lab), you should add a "\n" to the beginning of your output to have the new data start on a new line ---++Copying a file * If it is a clean copy, see the class example. You can just read then write each line. * If you are modifying the file, you need to change the line that has the data on it. The rest of the lines are just read and written as is
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2024-06-13
-
CathyBareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback