aspose file tools*
The moose likes Beginning Java and the fly likes What is meant by calling native API while working with Buffered streams Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is meant by calling native API while working with Buffered streams" Watch "What is meant by calling native API while working with Buffered streams" New topic
Author

What is meant by calling native API while working with Buffered streams

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi everybody, I have one doubt regarding native APIs with Buffered streams.

Buffered input streams read data from a memory area known as a buffer; the native input API is called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full.

What i understood from this line
Buffered input streams read data from a memory area known as a buffer
is that buffered readers or writes directly access the files from the hard disk instead of depending on the underlying Operating system.

What is meant by
the native input API is called only when the buffer is empty


Thank you all in advance.


Love all, trust a few, do wrong to none.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

chaitanya karthikk wrote:
What i understood from this line
Buffered input streams read data from a memory area known as a buffer
is that buffered readers or writes directly access the files from the hard disk instead of depending on the underlying Operating system.


That is not how I would read it. Rather - what it says is there is a space in Memory (RAM) which holds the data. The buffered input stream will access the data stored in the memory - not directly from the disk.

What is meant by
the native input API is called only when the buffer is empty

That means when there is no more data available in memory (RAM), then the OS / input type specific calls will be used to retrieve data to put into the buffer. For buffered File input streams that would mean accessing the file on disk and moving data from hard storage into the buffer (memory).

Steve
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thank you Steve for clarifying this point. However initially the file is not in RAM, so a native API call must be made definitely. What do you say?

Thank you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18672
    
    8

Of course the JVM needs to call a native method to ask the operating system to get data from the file system. This applies to all input, not just to buffered streams. And yes, native methods are required to ask the operating system to put data into the file system.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thank you Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is meant by calling native API while working with Buffered streams