• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing from variables into a file

 
Anshul Singhal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello people,
I m working on this code.



This is a section of code. I m trying to retrieve links from a webpage whose contents are there in pagecontents variable. While m in the loop I m storing them in link variable but not able to write them in the file links.txt. But in output file is created but no data in written on it.
 
Henry Wong
author
Sheriff
Posts: 22532
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm assuming that the file will eventually be closed in another section of code?

Henry
 
Anshul Singhal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL...well thankx it worked....I didn close the file. But I still dont understand why did that happen. In my original java program I am able to write to a file without closing it..!!
 
Henry Wong
author
Sheriff
Posts: 22532
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anshul Singhal wrote: In my original java program I am able to write to a file without closing it..!!


Did your original program exit? Did you de-reference the stream object and GC'ed? Either of these will close the file.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!