Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static void checkResponse(int[] response) throws Exception { if (response == null) throw new Exception("Null response."); if (response.length < 2) throw new Exception("Invalid response length, should always be 2 or more."); if (response[response.length - 2] != 144 || response[response.length - 1] != 0) throw new Exception("Card returned error codes (SW1SW2 = " + response[response.length - 2] + " " + response[response.length - 1] + ")."); } private static void checkResponse(int[] response, int expectedLength) throws Exception { checkResponse(response); if (response.length != expectedLength) throw new Exception("Unexpected response length."); } }