Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading data from file in an object (Simulation of "fread " function of c++  RSS feed

 
Sudhir Pandey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
See if possible or not ?
I want to read data from a file , in a structure(wait i know there is no strut. in java)from a file having just stream of bytes..(As we do in C++ Fread(),Fwrite() functions).

Is it possible that we can define a class having Fields as that in struct. and create an object of that class & read data in it.
I don't know whether it's possible or not
if yes please reply soon.....
Thank u
Sudhir Pandey
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not an expert in c++: fRead, alias Fread.
(looks like Fred).
Perhaps serialisation is what you're looking for.
But when your 'struct's are made of simple types (int, byte, char, ...), it will be easy to read a struct from a file.
Do you know the binary representation?
If you write the data yourself, you may choose between a compact dataformat (binary) or bigger, but readable data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!