Computer Science Canada File I/O ... Reading and Writing to a file |
Author: | Kuntzy [ Tue Sep 28, 2004 9:55 am ] |
Post subject: | File I/O ... Reading and Writing to a file |
Can anyone plz give me a tutorial on reading and writing to a file in java console? I searched the tutorials in java but i couldn't find what I need ... maybe sum example like opening a file with numbers in it and modifying them. |
Author: | .hack [ Thu Oct 14, 2004 8:35 am ] | ||
Post subject: | |||
I second this motion. My Programming taecher doesn't even know Java yet some how he got a job teaching it. So his way of teaching us is telling us what to read out of thise POS holtsoft book and learn it that way using "Ready To Java" (Actually named, "Wasting Your Time"). Anyways the book has l9ike 4 pages on IO except the code they give you doesn't work because this book was made by a group of tools. Example.
Now, is the book they don't TELL YOU that you need to import Java.io and they tell you that youneed to enter "throws IOException" in there somewhere, but it doesn't tell you where. God help us. or COmpsci ![]() |
Author: | wtd [ Thu Oct 14, 2004 2:33 pm ] | ||||||
Post subject: | |||||||
If you're frequently doing complex, specialized file I/O, it can be useful to extend the classes in question and add methods which do what you want. An example from this thread:
A new MoneyReader was created by:
And I used its functionality with:
|
Author: | Hikaru79 [ Sat Oct 16, 2004 3:57 pm ] | ||
Post subject: | |||
Here's a clue ![]()
That will work if you use it correctly ![]() |
Author: | wtd [ Sat Oct 16, 2004 6:01 pm ] | ||||||
Post subject: | |||||||
Hikaru79 wrote: Here's a clue
![]()
That will work if you use it correctly ![]() That won't compile. You haven't declared the variables "fileName" or "line". Additionally, you didn't import java.lang, but you did import java.awt, which doesn't do anything in this sample.
Instead, this could be rewritten:
|
Author: | Hikaru79 [ Sat Oct 16, 2004 10:51 pm ] |
Post subject: | |
Oh, my bad about the java.awt.* . ![]() |
Author: | wtd [ Sat Oct 16, 2004 11:13 pm ] |
Post subject: | |
It's ok. I just find it useful, when providing assistance, if you're going to provide code, if you can test it, you really should. There's a tendency for students who know nothing to assume that they did something wrong when they can't compile code provided by someone they perceive as more knowledgeable. |
Author: | Hikaru79 [ Sun Oct 17, 2004 9:26 am ] |
Post subject: | |
wtd wrote: It's ok. I just find it useful, when providing assistance, if you're going to provide code, if you can test it, you really should.
There's a tendency for students who know nothing to assume that they did something wrong when they can't compile code provided by someone they perceive as more knowledgeable. I never thought of it that way =/ I was just thinking it was a way to at least make them read the code ^ ^;; See what's missing. But you're right. I'll be careful next time ![]() |
Author: | Kuntzy [ Mon Oct 18, 2004 9:53 pm ] |
Post subject: | |
Well i got the ready to program version of file IO working ... too bad its not real Java ... |