File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes why does this not work? >:( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why does this not work? >:(" Watch "why does this not work? >:(" New topic
Author

why does this not work? >:(

Eric Johnson
Ranch Hand

Joined: Apr 30, 2001
Posts: 49
i am a newbie tryin to learn the language. i am messing with writing files and can't get it to work. here is what i tried, not knowing what i was doing but looking over the api and trying to go from there:

it creates a text file, but without any contents. ok, so before i get too frustrated with this i decide to look in the book from my class, and try the code there. it doesn't work either. it creates an empty file also.
this is from sun's java programming language class sl-275:

why can i not write a file that actually contains something? please help, i am becoming disillusioned.
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited September 07, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Just add a line
toWrite.flush();
after you do your write().

"JavaRanch, where the deer and the Certified play" - David O'Meara
Eric Johnson
Ranch Hand

Joined: Apr 30, 2001
Posts: 49
THANK YOU! that's what i get for ignoring methods i don't think i will have to bother with.
i imagine adding toWrite.close() will do the trick also. i'm not sure what the difference is, but i will research it. thanx again, i don't feel so dumb now. oh, and thanx for formatting the code. i will try and do that in the future.
[This message has been edited by Eric Johnson (edited September 07, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
No problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why does this not work? >:(