• Post Reply Bookmark Topic Watch Topic
  • New Topic

file io  RSS feed

 
nizar malaikah
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello , i want to write to file in java that's my code



the file exists but nothing is printed to it .
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The writer must be flushed and closed. Are you doing that in a finally block?
 
nizar malaikah
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i only did that
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so you didn't close the file. You'll have to add that: out.close();
 
nizar malaikah
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Ok, so you didn't close the file. You'll have to add that: out.close();


thank you that worked , do i have to do the same with a file that i take inputs from ??
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java7+ you should use try with resources which instructs the JVM to close the writer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!