• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Binary file vs Java ASCII File

 
Sashi Gundoji
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to Java. If I want to write lot of doubles number into a file, which one is the best. Writing in the format of Binary or in the format of ASCII.

Please give me suggestion.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Dimpu-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, it would be very unusual to write out the numbers in binary format. What is the reason you are considering that?
 
Harjit Singh
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Binary would be the best way to do it
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Best" depends on what your goals are. Writing the numbers in binary may be slightly more efficient for the computer - especially if the numbers typically have more than three digits. In this case binary would use less space. On the other hand, there's the disadvantage that it's harder for regular humans to look at the contents and see what's there. Also if the file needs to contain any info besides numbers, text is probably a little more flexible. For example if the numbers occur in groups of different sizes, you could put each group on a different line, and use commas between individual numbers. Maybe these things matter to you, and maybe they don't. There is no one "best" answer here.
 
Sashi Gundoji
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hallo,

thanks for the more info. It really did help me lot. Once again thank you all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!