Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:21:32+00:00 2026-05-27T13:21:32+00:00

I can’t write data at index above 128 in byte array. code is given

  • 0

I can’t write data at index above 128 in byte array.
code is given below.

private void Write1(APDU apdu) throws ISOException
{
    apdu.setIncomingAndReceive();
    byte[] apduBuffer = apdu.getBuffer();
    byte j = (byte)apduBuffer[4];       // Return incoming bytes lets take 160
    Buffer1 = new byte[j];              // initialize a array with size 160
    for (byte i=0; i<j; i++)
        Buffer1[(byte)i] = (byte)apduBuffer[5+i];
}

It gives me error 6F 00 (It means reach End Of file).

I am using:

  • smart card type = contact card
  • using java card 2.2.2 with jcop using apdu
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:21:32+00:00Added an answer on May 27, 2026 at 1:21 pm

    Your code contains several problems:

    1. As already pointed out by ‘pst’ you are using a signed byte value which works only up to 128 – use a short instead

    2. Your are creating a new buffer Buffer1 on every call of your Write1 method. On JavaCard there is usually no automatic garbage collection – therefore memory allocation should only be done once when the app is installed. If you only want to process the data in the adpu buffer just use it from there. And if you want to copy data from one byte array into another better use javacard.framework.Util.arrayCopy(..).

    3. You are calling apdu.setIncomingAndReceive(); but ignore the return value. The return value gives you the number of bytes of data you can read.

    The following code is from the API docs and shows the common way:

    short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
    if (bytesLeft < (short)55) ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
    short readCount = apdu.setIncomingAndReceive();
    while ( bytesLeft > 0){
    
         // process bytes in buffer[5] to buffer[readCount+4];
    
         bytesLeft -= readCount;
         readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody tell what is the best(easy) way to sort the following string 'index'
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can i get the source code for a WAMP stack installer somewhere? Any help
Can't work out a way to make an array of buttons in android. This
Can we close all known/unknown connections to database with the code? I'm using Access
Does anyone know how can I replace this 2 symbol below from the string
Can anyone can confirm the best idea for storing jquery code, initially i was
can any one tell me how can change this java code into objective c.is
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.