Note that there are some explanatory texts on larger screens.

plurals
  1. POUsage of BufferedInputStream
    text
    copied!<p>Let me preface this post with a single caution. I am a total beginner when it comes to Java. I have been programming PHP on and off for a while, but I was ready to make a desktop application, so I decided to go with Java for various reasons. </p> <p>The application I am working on is in the beginning stages (less than 5 classes) and I need to read bytes from a local file. Typically, the files are currently less than 512kB (but may get larger in the future). Currently, I am using a <code>FileInputStream</code> to read the file into three byte arrays, which perfectly satisfies my requirements. However, I have seen a <code>BufferedInputStream</code> mentioned, and was wondering if the way I am currently doing this is best, or if I should use a <code>BufferedInputStream</code> as well. </p> <p>I have done some research and have read a few questions here on Stack Overflow, but I am still having troubles understanding the best situation for when to use and not use the <code>BufferedInputStream</code>. In my situation, the first array I read bytes into is only a few bytes (less than 20). If the data I receive is good in these bytes, then I read the rest of the file into two more byte arrays of varying size.</p> <p>I have also heard many people mention profiling to see which is more efficient in each specific case, however, I have no profiling experience and I'm not really sure where to start. I would love some suggestions on this as well.</p> <p>I'm sorry for such a long post, but I really want to learn and understand the best way to do these things. I always have a bad habit of second guessing my decisions, so I would love some feedback. Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload