ByteArrayInputStream read with offset

I have a ByteArrayInputStream that I want to read from specific position after initializing. So for example:
byte [] bdata = //Some data
ByteArrayInputStream bt = new ByteArrayInputStream(bdata);
I want to be able to point to position 4 and read 8 bytes and then read 3 bytes pointing to position 6 starting from the next of last read byte, in this case position 12, since last read was 8 bytes from position 4. So if I have
123456789ABCDEFGHIJKLMNOP
first read would get me: 456789AB
second read would get me: HIJ
I was thinking of using read with offset but that is not quite working properly. May be I could use skip but I am not sure how it works.

Are you reading binary data, or are you reading text? If it's text, why are you storing it in a byte array?
If it's actually binary data, then look at the read(byte[] b, int off, int len) method, it lets you read len bytes from the off starting position. It stores what it reads in the b array.
If it's actually text that you're trying to read, then use the Reader class instead. It's much like an InputStream, but designed for text instead.

Similar Messages

  • Replacement path variable with offsets

    Hi experts,
    I have the requirement to report receivables (open items) historically by fiscal year / period.
    More precisely, each period should show the open items that are open at the end of the period.
    Example:
    001.2010 (shows open items from 31.01.2010)
    002.2010 (shows open items from 28.02.2010)
    ...etc.
    The idea is that the user enters a fiscal year/period using a manual entry variable.
    The open items should be calculated as follows:
    KF: Amount
    Posting Date <= Variable
    Clearing > Variable or unassigned
    Variable is a replacement variable that is replaced by attribute "Date To" from the user entry Variable (Fiscal year period)
    E.g. if the user enters 008.2010, then this value is automatically replaced by 31.08.2010.
    Generally this works.
    However, to view the values for the last 12 months, a structure is needed consisting of 12 elements with offsets in order to show the 12 months prior to the selected period (e.g. 001.2010 - 002.2010 - 003.2010 ....etc.)
    The problem is that the replacement only considers the user's variable entry and ignors the offsets.
    Example:
    User enters 008.2010.
    In the column strucure I show 3 months 006.2010, 007.2010, 008.2010.
    Then all columns would show items open on 008.2010 - the offsets are ignored.
    Any idea, why this happens and how it can be resolved?
    This problem has given me a headache for days.
    Your help is much appreciated.
    Thanks and regards,
    Alex
    The user should be able to enter a fiscal year / period and

    take an e.g.
    u have characteristic say ch1
    u want to restrict it with replacement path variable
    first of all create a variable var1
    click what it is based upon for e.g. 0calday, 0material etc.
    make it user entry variable
    select single or multiple entry
    make it mandatory
    save it and hit okey
    click on ch1
    right click and say restrict
    in new window create a new variable
    give its name and technical name
    processing path is replacement path
    go to next tab of replacement path
    select several ooptions
    replace variable with another variable
    select a variable called var1
    change the offset length and offset start with different parameters.
    hit okey
    this way u have restricted ch1 with replacement path variable var1
    now when u run report u have to enter value of var1
    which will then further feeded to ch1
    this way u can create replacement path variables at lots of instances and then u can always feed the value from var1 at different time
    make sure as this ur requirement is date
    try to use 0calday as reference infoobject all the times....

  • Problem with offset length

    Hi,
    i have a problem with offset length please see below code and suggest :
    data: content_new                LIKE soli-line.   "It has a length of 255 charecter
    content_new = 'MTE:SD0\nwssd01_SD0_00\CPU\CPU_Utilization'.
    content_new = content_new+4(251).
    it is giving result:
    content_new = SD0\nwssd01_SD0_00\CPU\CPU_Utiliza  "it is removing last 4 charecter of UTILIZATION also
    while i need :
    content_new = 'SD0\nwssd01_SD0_00\CPU\CPU_Utilization'.
    can anyone plz help me?
    regards.
    Moderator Message: Duplicate Post.
    Edited by: kishan P on Oct 28, 2010 9:44 AM

    You can find string length first. Subtract length by 4,  Then use like new = str+4(len), use condense if required.

  • Contract a path with Offset?

    I have a path that turned out to be a litt ethicker than it needs to be.
    I see that I can expand a path with Offset Path. I have read online that you can contract a path by entering a negative number, but when I try that, it ignores the minus sign and expends the path instead.
    Is there some other way to contract the path?

    I think it is closed. It looks closed. (See attached.) I have even tried to use the knife tool to cut a circle around the entire  path, but no dice.

  • Problem with offset values

    Hi Experts,
    I have a problem with offset values. I have create a variable on OFISCPER, it's characteristic value, indivdual value, mandatory and ready for the input. I need to show the varibel period and the l previous period and so on till 12 periods. I used the offset values (-1, -2, etc.) but when I execute the query I can show just the variable period and the period previous I don`t see. The query is based on multiprovider and don´t has filters. Can anyone help me?

    Leonel,
    You may nt need to have 12 columns in the query designer.
    You could include the keyfigure and restrict it to the variable and create the offset for the 12 periods
    Check this http://help.sap.com/saphelp_nw04/helpdata/en/00/e8d13f7fb44c21e10000000a1550b0/frameset.htm
    -Doodle

  • Adobe Reader Splash--I have a PDF file that whenever I try to open it suggests using Adobe Reader with a link to download Adobe Reader...

    Adobe Reader Splash--I have a PDF file that whenever I try to open it suggests using Adobe Reader with a link to download Adobe Reader. I can't get beyond this. I have made Preview the default for all PDF's and yet this persists. I have also deleted Adobe Reader. This particular file is a portfolio, btw.

    I have similar issue. Did u find an answer?

  • Mac-formatted FAT32 external drive: cannot read with windows

    I'm posting here in the hopes that it's a mac problem. I have 2 external drives, each USB and each very large (120+GB each). both contain a few files larger than 4 GB each. I formatted each drive using my Mac, one in Leopard and one previously in Tiger; each is FAT32 formatted and can be read easily with my Macbook in Leopard. I also have a 4GB flash drive that is FAT32 formatted, which was formatted using my Macbook.
    when I plug either drive into a Windows machine (Vista or XP Pro SP2) it goes through the new hardware wizard but the drives do not show up in Explorer. the disk management service shows the drives but they appear as "unallocated space" and cannot be accesed. the option I have when I right-click on the drive is "Initialize". I sold my Macbook and don't have access to it anymore, and even if I did, the process of moving all of these files (a total of ~150GB) to an FTP server and then onto my new Vista machine is not possible. the even weirder thing is that my FAT32 formatted flash drive shows up on any windows machine without a problem.
    Can someone explain what might have happened here? since the drives are both easily readable with any Mac (I've tried two, one with Leopard and one with Tiger) and they both show up in the Mac as FAT32 formatted, I can't imagine why they cannot be read with a Windows machine.

    You cannot give yourself full access when connected like this. It is not supported. the only way to access an NTFS device with write privileges is while it is connected to a Windows host. This is because your Mac doesn't know what to do with the ACL information. While it's connected to a Windows host, you can get at the share and use the host's information to authenticate to it.
    If you want to use it directly attached to the Mac, you need to have it formatted in a Mac readable format. Mac OS Journaled, HFS+, FAT32 among others... It'll need to be FAT if you want Windows to access it too though (and you can't set permissions on FAT drives like you can NTFS or HFS etc).

  • How to fill forms in adobe reader with lithuanian fonts?

    How to fill forms in adobe reader with lithuanian fonts?
    when i switch on my pc alt+shift to lithuanian language i can only use 2 lithuanian fonts, for other lithuanian fonts i get only blank
    could someone help me to solve this case?

    Adobe Acrobat.  A bit expensive just to change the document background...

  • I am using Adobe Reader with paid up service through May 2015.  When I attempt to convert a file from PDF or to PDF, I get the message "An error occured while trying to access the service.  What do I need to do to access the service paid for?

    I am using Adobe Reader with paid up service through May 2015.  When I attempt to convert a file either to PDF or from PDF, I get the error message, "An error occurred while trying to access the service".  What do I need to do to get access to the service I have paid for?

    Hi DeaconTomColorado,
    Please see "Error occurred when trying to access this service" when logging on to Acrobat.com.
    Adobe has just released an update to Adobe Reader, so if you're accessing the service via Reader, please let us know whether the update helps resolve the issue.
    Best,
    Sara

  • Is there a limit on the size of SDHC card that can be read with the iPad camera connectioin kit?

    Is there a limit on the size of SDHC card that can be read with the iPad camera connection kit?

    I've successfully connected 32 gig SDHC and CF cards so if there is an upper limit, it's at least 32 gig.
    I know SDXC will not work.
    With the cards that don't work, have they been formatted correctly? the camera connection kit will only read cards holding images. (Well, it'll only see the images) And those images have to have a file name of exactly 8 characters (DSC_2342 for example) and they  have to be in a folder named DCIM.
    Anything else it wont' read.
    I put a photo on there called 'Christmas' and the connection kit won't see it. I put a photo on there in the DCIM folder named XMAS2342 it'll see that.
    So it's possible that those cards weren't read because they weren't speaking the right language.

  • Problem in reading with DOM

    i have the following xml file to read with DOM
    <?xml version="1.0" encoding="UTF-8" ?>
    - <usecasediag>
    - <actor id="1">
      <name>customer</name>
      <usecase>reservation of tour</usecase>
      <usecase>view tour data</usecase>
      <usecase>cancel reservation</usecase>
      <usecase>complain</usecase>
      </actor>
    - <actor id="2">
      <name>employee</name>
      <usecase>access</usecase>
      <usecase>update</usecase>
      </actor>
    </usecasediag>after reading the above file i need to create another XML file using DOM. I have the following code but i am not able to get the value "customer","enployee" while reading the XML file....
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.*;
    import javax.xml.parsers.ParserConfigurationException;
    import com.sun.org.apache.xml.internal.serialize.OutputFormat;
    import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
    class Post
       Document dom; //to read
       Document dwrite; //to write
       Element root;//to read
       Element rootEle;//to write
       Post()
            File docFile = new File("..\\uml\\xml file\\sample.xml");
            try {
                DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                dom= db.parse(docFile);
                  } catch (java.io.IOException e)
                System.out.println("Can't find the file");
                } catch (Exception e)
                System.out.print("Problem parsing the file.");
            Element root = dom.getDocumentElement();
            findActor();
    void findActor()
         Element ele=null;     
         NodeList nl1 = dom.getElementsByTagName("actor");
         if(nl1 != null && nl1.getLength() > 0)
             for(int i = 0 ; i < nl1.getLength();i++)
                   //get each actor element
                   ele = (Element)nl1.item(i);
                   Node nameEle=ele.getFirstChild();//name element
                   Node actnm=nameEle.getFirstChild();//customer
                   String clname=actnm.getNodeValue();
             }//for
         }//if               
    }//classcan anyone figure out the problem...thanx in advance

    you are right...its taking empty tag...i tried doing it some other way but the control is not matching the "if" statement....can you please tell me how do i write code to get the name & usecase element for each actor..
    void findActor()
         Element ele=null;     
         NodeList nl1 = dom.getElementsByTagName("actor"); //all actor tags in XML
         if(nl1 != null && nl1.getLength() > 0)
             for(int i = 0 ; i < nl1.getLength();i++)
                   //get each actor element
                   ele = (Element)nl1.item(i);
                   for(Node child=ele.getFirstChild();child!=null;child=child.getNextSibling())
              if(child.equals("name"))
              { System.out.println("got it");
                   break;
             }//for i loop
         }//if               
    }

  • Vol of the HD be read with labvew 7

    hi,
    how can the vol of the HD be read with labvew 7 without using the system exe?

    Hi,
    You can do this by using the volume info VI located in the file pallette/advanced file functions/volume info.
    Place it on the block diagram and wire indicators to it at a path constant.IF you want to know the volume of drive C just type in c: if you have more than one drive letter and want to know the total volume just do one for each and add them together. I'm sure ther is a better way this is just a quick one.
    Joe
    Joe.
    "NOTHING IS EVER EASY"

  • Using lightning to SD Card Camera Reader with iPhone 6 plus

    Using lightning to SD Card Camera Reader with iPhone 6 plus gives me the message that it is incompatible.  Is that correct?

    Yes. The Camera reader is not compatible with iPhones.

  • Want: Adobe Reader with Firefox but not with Safari

    I've been using Firefox as my primary browser for awhile, but still use Safari at times. I use Adobe Reader to display PDFs within Firefox, and it is currently also used by Safari.
    I'd like to take advantage of Safari's new ability to natively display PDFs within the browser window without using Adobe Reader, but I want to continue to use Reader with Firefox.
    Does anybody know of a way to make this happen? It seems to be an all-or-nothing proposition since the same plug-in is used by both browsers.
    iBook G4 12"   Mac OS X (10.4.6)   It's white.

    well, you might try quitting safari & firefox, then moving the adobe plugin(s) from /hd/library/internet plug-ins/ to /applications/firefox.app/contents/plug-ins/ In finder, press Apple-shift-G & paste the italicised text above into the box - this will take you to the firefox plug-ins folder ( assuming you have firefox in the applications folder )
    then restart the browsers & see what happens
    Please note - I don't know that this will work, but it's easy to try & easy to revert back to normal - just quit the browsers again & move the plugin(s) back where they came from.
    I'll just test it with a different plug-in......

  • Customer Exit Variblae with Offset

    Hello Everyone,
    Can any one tell me whether we can use offset on Customer Exit Variable or no?
    I have
    Variable 1. Calmonth_01 in first Column which is also input varialble.
    Variable 2. Calmonth_02 is second Columnt which is Exit  Variable on which offset is not applied.
    From third Column i m using second variable with offset.
    According to me it has to work. but i m report it is not working.
    Plz help.

    Hi,
    If you have any Input Variable on 0CALMONTH and based on the input month if you want to display the reports either + or 1 Months then you can use Off Sets it will work, no need to go for Customer Exit Variables.
    1. Create a User Entry Variable on 0CALMONTH eg name of variable = ZMNTH
    2. Restrict the Keyfigure with ZMNTH in column one.
    3. Restrict the Keyfigure with ZMNTH-1 in column two, it will display Previous month data based on Input month
    4. Restrict the Keyfigure with ZMNTH+1 in column three, it will display next month data based on Input month
    Steps 3 & 4 are using Off Sets only.
    For any Customet Exit variables see
    https://wiki.sdn.sap.com/wiki/display/profile/Surendra+Reddy
    Thanks
    Reddy

Maybe you are looking for

  • MacBook Pro won't recognize videos on my Canon Vixia HG20

    I have a Canon Vixia HG20 and had no trouble copying video to my Mac laptop in the past. Now I have a MacBook Pro and when I connect the camera with a USB cable, the videos are grayed out and the computer doesn't recognize them. The videos play fine

  • Setting recurring events in calendar

    I have an I phone 4. I am trying to set recurring meetings that occur for example; on the second Wednesday of every month. On the repeat selection, there is no option for that. I find this very odd as many professionals have recurring events and meet

  • Change GDM language in Gnome3 and add a Second Language to the List

    Hello Everyone, I have always used this order in my language list in Gnome or KDE : Portuguese, French, English. But since the update of Gnome 3.2.1, I have problems defining the language, on my locale.gen I got only those 3 languages activated. But

  • Windows Updates on Server Core

    I am having no updates on Windows 2008 R2 SP1 Server Core for 2 years. Initially, as I installed them, I ran sconfig, manual updates and it downloaded a bunch of updates at that time. But since then I always get "No applicable updates" I checked the

  • Ora 12543 tns destination host not reachable

    Dear All, OS: RHEL 5 DB VERSION:-11.2.0 I am facing problem related to ora 12543 tns destination host not reachable The problem here is little bit different what exactly other face:- i have 2 servers with name abc.localdomain & xyz.localdomain. Db na