Java examples for javax.smartcardio:CardChannel
read Card Data
//package com.java2s; import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; import javax.smartcardio.CommandAPDU; import javax.smartcardio.ResponseAPDU; public class Main { public static byte[] readData(Card c, byte block) throws CardException { byte cla = (byte) 0xFF; byte ins = (byte) 0xB0; byte p1 = (byte) 0x00; byte p2 = block; byte le = (byte) 0x10; byte[] params = new byte[] { cla, ins, p1, p2, le }; CardChannel channel = c.getBasicChannel(); CommandAPDU command = new CommandAPDU(params); ResponseAPDU response = channel.transmit(command); validateResponse(response);//from w w w . j a va2 s . c om return response.getData(); } private static void validateResponse(ResponseAPDU response) throws CardException { if (response.getSW1() != 144) { throw new CardException( "No fue posible cargar la autenticaci?n"); } } }