Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
I/O and Streams
program to write 1000000 lines
Noble Bhaskar Aswanapally
Greenhorn
Posts: 13
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have below program to print 1,000,000 lines
. But its printing 998976 only to file. Any issue in the code?
public static void main(String a[]) { try { BufferedWriter writer = new BufferedWriter(new FileWriter( "C:\\Documents and Settings\\A.Bhaskar\\Desktop\\input.txt")); for(int i=1; i<=1000000; i++) { writer.write(" "+i); writer.write("\n"); } } catch (IOException e) { e.printStackTrace(); } }
Ulf Dittmer
Rancher
Posts: 43081
77
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Any Writers should be flushed and closed when you're done with them.
Noble Bhaskar Aswanapally
Greenhorn
Posts: 13
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Ulf Dittmer wrote:
Any Writers should be flushed and closed when you're done with them.
Thank you very much Dittmer. I got correct output after closing.
Always look on the bright side of life. At least this ad is really tiny:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to write a new line on a file
File IO - BufferedWriter/FileWriter
QuizCard txt file - newline missing
HELP!!!
Reading first 10 lines from a file and writing it into another file
More...