• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a file

 
Yogesh Chhawasaria
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Say theres one file of X MB and I want to read it entirely and display the decimal value represented by these X MB of data. Can anyone guide me how to begin with.

[By decimal value I mean : all bits finally represent something in decimal; How can I convert X MegaBits to Deciaml value and perform arithmetic operations on this value]

Thanks in advance
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure whether i have understood u'r question fully ..

If u need a decimal value for each & every character in a file , why cant you use the ascii value of each character stored in the file .
[ October 17, 2004: Message edited by: srini vasan ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you perhaps talking about something like java.math.BigDecimal?
On the other hand - if you want to get a number that somehow characterizes the content of a large file, perhaps you want something like a message digest - see java.security.MessageDigest
Bill
 
Yogesh Chhawasaria
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ill clarify my question once more

Say theres file of size 1kb These 1024 bytes (1kb) = 1024*16 bits must be representing a final decimal value
I need this decimal value and want to perform arithmetic computations on it.

Its easy to get that decimal value for small size file; for bigger files I used BIgInteger and somehow managed it. But after a fixed size I cannot sem to read entire file contents and get that final value maybe ram limitations

What I really want is that say theres a 2GB file then that file can be represented using a unique decimal(integer) value I just want to get that value but cant seem to...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, with 2GB of data, you're going to bump into hard limitations of many JVMs. Sun's Linux and Windows JVMs both have heap size limits somewhat below 2GB. Your only option for directly dealing with data of this size would be to go to another language -- C/C++, probably -- and a 64 bit architecture. You can certainly play games whereby only part of the data comes into memory at once, but that adds a lot to the complexity of your code.

I'm quite interested now -- what sort of work are you doing that involves integers with 2 billion digits?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic