• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1939
  • Last Modified:

fread in java?

Hello all;

i want to write fread in java

int  fread (void * buffer, size_t size, size_t count, FILE * stream);
Read block of data from a stream.
  Read count number of items each one with a size of size bytes from the stream and stores it in the specified buffer.
  Stream's postion indicator is increased by the number of bytes readed.
  Total amount of bytes read is (size x count).


how can i do it ?
0
dervisakyuz
Asked:
dervisakyuz
1 Solution
 
dbkrugerCommented:
This is hardly the place for this question (Java questions belong in the Java TA) but since you asked....
There is a class in Java called InputStream, and since you can read an array of bytes from it, I don't see why you should need to write any code at all, except that it specifies the array of bytes, and you have size and count.
int sz = ____________; // set your size to be size * count
InputFileStream is = new InputFileStream("file.dat");
is.read(buf, 0, sz);
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now