Why is there only read(byte[]) & not read(int[])

I'm trying to read large raw images using the RandomAccessFile. Different images are of different types, some are uInt8, some are int8, some are int16, uInt16, float, etc. The only way I know to read them fast enough is by reading an array of bytes, and then putting the bits together into a new array of the desired type, e.g. shifting and adding to the bytes.
I'm sure there's a clever way to read different types really fast... How?

Well... Is there any possabilities to create a new
int[] array that is "pointing" at the same memory
allocation as the byte[], just as you can do in C or
other languages with pointers?
Nope, Java is type safe.
It would be easy if I could make the compiler
interpret the byte[] as an int[]... Suggestions?
Create a java.io.DataInputStream to read from a java.io.ByteArrayInputStream that reads from your byte[] is one option:ByteArrayInputStream byteStream = ByteArrayInputStream(anArrayOfBytes);
DataInputStream integerStream = new DataInputStream(byteStream);
int firstInt = integerStream.readInt();
...If you need random access to an int array maybe you need to create the array first and the read ints to it...

Similar Messages

  • Why my self-signed applet could not read local disk but could write?

    I used a self-signed certificate for the applet yesterday and it worked
    fine at the beginning time, that is, it could write/read file to/from
    local disk, and it could connect to other MDS servers. But later, a
    problem happens. It could write file to local disk(I tested it and created
    files to C:/ under windows) but when it try to read that file, it got a
    io acessing exception. It could connect to other servers. I am puzzled
    about this problem, and I wonder why I could write but could not
    read. Need I deal with any policy file issue here?

    hi,
    i 'am doing something which is similar to the stuff ur doing .I wanted to write into file on the local disk on which the applet is running.for this i have signed the applet .do i need to make it self signed wat is difference between the self signed and signed applet .The problem which i facing is that it still gives me the security exception even if i define the policy file for that applet............Can u help me reagrding this
    Thanks in advance
    your great help would be apprecriated
    rao_lavs

  • Why is there only one automated audio fader at head and none at tail of some audio clips?

    When I select "Show audio animation," top left of an audio clip, on some sections I have two knobs... one at the head for fade in, and one at the tail for fade out. Why is there only one on some of the audio clips and not both? I've set up the clips the same, regarding audio animation, and some have faders at head, but not tail. How do I make another fader at the tail of a clip? Or why doesn't it automatically behave like the other audio clips that DO have two faders? I don't know what I'm doing to make them act differently.
    Thanks,
    Michael

    Tom,
    Thanks for reply. I'm attaching screen shots. For some reason my pointer didn't show up with a normal screen grab. Don't understand. Anyway, several versions are attached. There isn't one hidden on the right beyond the frame that pops out when I put my pointer there (or any tool). Strange.

  • Why is there only one Operating Concern defined in GBI?

    Hi all,
    I have the following question: when looking at the CO structure of the GBI case study, why is there only one, global operating concern defined? According to the definition of an OC, it is the level whereupon profitability analysis is performed. So why is in GBI that has two very distinct business areas not at least two OCs defined (one per business area), if not more (per product)?
    As a follow-on, what is then the relation between OC and Controlling Area? I am looking for a plain English explanation that I can also use for teaching purposes.
    Thank you in advance for reading!
    Regards,
    Gerhard

    Hi Gerhard,
    I hope my reply is not too late.
    I agree with you.  Profitability analysis is typically done at a detailed level - by market segments, which may be defined by geographical segments, customer groupings, product groupings, salesforce grouping, etc.  CO-PA does support profitability analysis at such detailed levels.
    After defining an operating concern and activating it, the system generates a series of database tables for the operating concern.  I took a screenshot of the (partial) structure of the "master" table for the global GBI operating concern, GL00, from the GBI 2.2 system I am using, below:
    As you can see, with such a table structure, CO-PA is capable of capturing profitability information at a very detailed level for reporting and analysis.
    You may also notice that operating concern is not a field in the table.  The reason is, the entire table (as well as its related tables in the same series) is used only for operating concern GL00.  Its name is even hard-coded in the last 4 characters of the names of these tables.  When CO-PA reports are executed in SAP ECC, they retrieve data from only one series of tables, i.e., only data of only one operating concern can be reported.
    Back to your question: Why is there only one operating concern and not two?  The wisdom of defining one global operating concern is that profitability data of both controlling areas (Europe and North America) will be updated into the same series of database tables and reported together.  If there had been two separate operating concerns for the two controlling areas, there would have been two series of database tables, making profitability analysis across the two areas difficult, if not impossible.
    Let me know if you need further clarifications.

  • Why cant itunes get it together? Why is there only one frank ocean video when in America there are more???

    why cant itunes get it together? Why is there only one frank ocean video when in America there are more???
    i have spent all day trying to buy or download kid Cudi's what I Am video but am being blocked every time. Why???

    Because the content providers have not released it for your country. I am guessing you are not in the US.
    This is nothing to do with Apple.

  • My adobe reader does not read my pdf files, I think it was screwed up by the other "PDF-READER". I deleted the other "PDF-READER" from my pc, but it still does not work.

    my adobe reader does not read my pdf filI think it was screwed up by the other "PDF-READER". I deleted the other "PDF-READER" from my pc, but it still does not work.

    Hi wellsfar,
    Which version of Adobe Reader you are using?
    Is it showing any error message?
    A screenshot of the error would be more helpful.
    Regards,
    Florence

  • Why are there only 10 options under "Set Metadata Format"?

    Why are there only 10 options under "Set Metadata Format"?
    These are:
    Caption
    Title
    Filename
    Author
    Copyright
    Comments
    Keywords
    Date/Time
    Aperture
    Shutter Speed
    Has anyone found a way to to change this?

    Hi.
    Can you find the "Comments" field into the Metadata? Because I don't find it and when I write something in the box Aperture tells me that the box is "unlink" from the metadata...
    How can I add a (free) comment to my photos in a book?
    Thank you very much for your reply
    Bye

  • JDBC to Lotus Notes, only 255 bytes be read for each field. Any clue?

    Hi,
    I am programming with JDBC to Lotus Notes. I can extract data from .nsf files but for each field, only 255 bytes can be read, all the rest got truncated. I ran the ResultSetMetaData.DisplayColumnSize(), it returns 255.
    What is the problem? How can I extract larger strings (such as 700 bytes)? I tried bloc data type, it doesn't help.
    In the API docs, there is a RowSetMetaData that has a SetColumnSize() method, but I can not find an implemented package of it, also not sure it will work. Any suggestion will be deeply appreciated!
    Thanks!
    William

    You must declare the filed Rich Text, not Only Text, because the Method GetString only get 255... although your filed have more caracters...
    If you declare rich Text you must use tgetAsciiStream Method...
    suppose the filed 2 is Rich Text...
                 byte[] buffer = new byte[4096];
                 int size;
                 InputStream strin = rs.getAsciiStream(2);
                 if(strin == null){
                    System.out.println("notas es null\n");
                 else {
                    for(;;){
                        try {
                        size = strin.read(buffer);
                        if(size <= 0){
                           break;
                        System.out.print(new String(buffer,0,size));
                        } catch (java.io.IOException e){
                           e.printStackTrace();

  • Bytes not read from DataInputStream

    I want to read a binary file and translate the data to ascii. In order to do so, I've decided to let one method take care of the opening and reading the data and this is where the problem is; no data is read from the binary file. When the for-loop is executed, the index is printed on the screen and since the number is increasing, it cannot be the for-loop that is malfunctioning. However, the data that should be read, should also be displayed, but that does not happen. Can someone tell me what is wrong with my code?
    Thanks
    Simon
    public void readFromBinary() throws FileNotFoundException,IOException
         //open stream
         FileInputStream fInputStream = new FileInputStream(inFile);
         int lengthInFile = fInputStream.available();
         inStream = new DataInputStream(fInputStream);
         byte[] values = new byte[lengthInFile];
         //read data
         for(int i=0;i<lengthInFile;i++)
    System.out.println("i = "+i);
         values[i] = inStream.readByte();
         String str = new String(values);
         System.out.println(str);
         System.out.println("readFromBinary: Data read, length is "+values.length);
         //close stream
         fInputStream.close();

    values[ i ] = inStream.readByte();You've only read one (more) of the bytes, the other
    values in the array are still zeros
    String str = new String(values);
    System.out.println(str);This doesn't make sense creating a string out of the
    array which just keeps adding one more byte every time
    thru the loop.
    Why not just read the thing as one operation?
    inStream.read(values);Actually meant:
    fInputStream.read(values);
    You shouldn't be using DataInputStream on a stream that wasn't created by a DataOutputStream. But then I don't know what this file is you're messing with.

  • Why are my new file contents not read?!

    Hi,
    I have a web application with a StartupServlet. In this Servlet my web application is initialised by reading out a file (init.xml) from disk. When the app server has been started and I modified the contents of the init.xml and reload the StartupServlet the new contents are not read. Only the old file contents are visible at the StartupServlet... The init.xml file is read using the ClassLoader.getResouceAsStream();
    Could someone please explain to me why the old file contents are read and not the new file contents???
    dee3lmo

    Notice that by simply accessing your servlet again, your servlet won't be reloaded!
    Please read the resource from your servlet using the ServletContext, as follows:
    getServletContext().getResourceAsStream("init.xml");
    instead of using the servlet's classloader.
    This will ensure that you will always read the most recent version of the resource, without having
    to reload your servlet.
    Hope this helps.

  • Why does my apple shuffle dock not read by my computer

    why does my apple shuffle dock not being read by my computer

    Are the connections on each end nice and snug?  Has this Shuffle ever previously worked with this PC or this the first time you have tried connecting it?
    It worked previously, can you think of anything on the PC that might have changed since the last time the Shuffle was able to successfully connect? Could be something such as an update to an application or the installation of some new software.
    Does the device charge when it is connected?  Do you get any status from the LED indicators when plugged in?  Does the Shuffle otherwise function as expected?
    B-rock

  • Why is there always "0 bytes" in Cache in Control Panel? It never increases, yet the stored data size continues to increase.

    This is annoying. I just updated to version 19 almost a week ago and still Firefox never seeks to keep anything in "Cache". After using firefox for a few days, it crashed a couple times already and now the browser randomly freezes (to the point to where my screen on/off button wont even respond). After maybe a few seconds...things will start moving, but sluggish to where I have to shut down FF in my task manager. There us "0" bytes cache shown, but stored data is at 70MB. I went into firefox and cleared cache via the settings but that did nothing. There is still 70MB of stored data and of course it alwats shows 0 bytes cache. What's up with that? Am I going to have to "Clear Data" just to fix this and lose my bookmarks and logins tet again?

    I think it's possible that Firefox, while emptying some database files, is not compacting them, so they continue to consume the same amount of "disk" space as they did before. On desktop versions of Firefox, you can use extensions such as the following for that purpose, but I don't know whether any such thing is available for mobile. Also, it would be nice to have it built in.
    * https://addons.mozilla.org/en-us/firefox/addon/places-maintenance/
    * https://addons.mozilla.org/en-us/firefox/addon/placescleaner/
    Unfortunately, in a quick search, I do not see a general purpose Android SQLite app that will runs on Firefox profile databases without root access (unless they are on the SD card, which seems highly doubtful).

  • Why is there an option for Notes Syncing?

    Hello,
    Looking to clear something up about Note Syncing. Why is this an option? When I make notes in Mail.app they live online in my inbox or other online subfolder and I can get at them from any of my other Macs that have Mail.app set to check that account.
    What am I missing here? Is the Notes sync item in mobile me syncing preferences for syncing offline notes, ones that you put in an "on my mac" folder? Why wouldn't you just put these notes up in the cloud like I do...it seems like there is no upside to this note-syncing ability.
    I have looked around for an official textual description of what Notes syncing is for but I can't find one. It seems to solve a problem that doesn't really exist. Can someone straighten me out, maybe there is a good reason why I should actually be syncing notes?
    Thanks!
    Ryan Hanson

    Yeah, I did find a lot of people posting that they wished for this feature for iPhone and it has been promised in the past. I do not have an iPhone, so the questions would be if you put a note in your inbox, how does the iPhone currently treat it when you check your mail? It would still seem that sync is unnecessary 'cuz the note still lives in the cloud. Ha ha I guess the bottom line is that I am not really trying to solve a problem, with or without Notes Syncing tuned on I can get to my Mail notes anywhere that I have Mail.app setup...but I was just wondering if I was missing out on something, you know, conceptually...

  • Reader will not read my pdf files. after an automatic update the pdf files are not accessable.

    adobe automatic update to XI caused the reader of my pdf files to stop working. The reader tries to open -- the adobe reader window opens for a few seconds, nothing in the window is activated -- then the window automatically closes.
    I have uninstalled and reinstalled previous versions that used to work but the reader 9 and X now do the same thing. open, unactivated window after a few seconds the program then shuts down.
    I cannot open and read any pdf file on this computer.
    There are no error messages and everything seems normal. The program does not work properly.
    I have ran the windows diagnostic tools to no avail.
    This computer operates windows 7

    See if you can open the EULA.exe file in the folder that contains the install of Reader or Acrobat.

  • Updated to firefox 4, and suddenly can't connect with any browser though I am connected. Error message reads "could not read chrome manifest file."

    i updated firefox and now I can't access the net on any browser. Wireless router everything is connected and up and running. Just not the browsers. uninstalled it, reinstalled it (didn't work), unistalled it again and internet explorer won't work either (not at anypoint after intial update was run. read several peoples simalr problems with the "could not read chrome manifest file" issue and solutions to no avail. uninstall and system restore did not work either. What did it change on my system, and how can I change it back?

    Do a clean (re-)install:
    Download a fresh Firefox copy and save the file to the desktop.
    * Firefox 4.0.x: http://www.mozilla.com/en-US/firefox/all.html
    * Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    * Do not remove personal data if you uninstall the current version.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    * It may not be necessary to create a new profile, so first try if it works with your current profile and if not then create a new profile.
    Your bookmarks and other profile data are stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder] and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    * http://kb.mozillazine.org/Standard_diagnostic_-_Firefox

Maybe you are looking for