List of usage examples for java.lang ArrayIndexOutOfBoundsException getMessage
public String getMessage()
From source file:au.edu.unsw.cse.soc.federatedcloud.user.CloudBaseUserInterface.java
public static void main(String[] args) { CloudBaseUserInterface interfaze = new CloudBaseUserInterface(); String command;// www . j a va 2 s. c om try { command = args[0]; if ("init".equals(command)) { String appName = args[1]; try { String appAttributes = args[2]; interfaze.initCloudBase(appName, appAttributes); } catch (ArrayIndexOutOfBoundsException aie) { log.warn("No attributes specified."); interfaze.initCloudBase(appName); } } else if ("deploy".equals(command)) { String resourceName = args[1]; String resourceMetaData = args[2]; interfaze.deployResource(resourceName, resourceMetaData); } else if ("undeploy".equals(command)) { String resourceName = args[1]; interfaze.undeployResource(resourceName); } else { System.err.println("Command: " + command + " is not specified."); } } catch (ArrayIndexOutOfBoundsException ex) { System.err.println("please specify a command."); log.error(ex.getMessage(), ex); } catch (IOException e) { System.err.println(e.getMessage()); e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
From source file:FactComputer.java
public static void main(String[] args) { // Try to compute a factorial. // If something goes wrong, handle it in the catch clause below. try {/* w w w . ja va 2 s . com*/ int x = Integer.parseInt(args[0]); System.out.println(x + "! = " + Factorial4.factorial(x)); } // The user forgot to specify an argument. // Thrown if args[0] is undefined. catch (ArrayIndexOutOfBoundsException e) { System.out.println("You must specify an argument"); System.out.println("Usage: java FactComputer <number>"); } // The argument is not a number. Thrown by Integer.parseInt(). catch (NumberFormatException e) { System.out.println("The argument you specify must be an integer"); } // The argument is < 0. Thrown by Factorial4.factorial() catch (IllegalArgumentException e) { // Display the message sent by the factorial() method: System.out.println("Bad argument: " + e.getMessage()); } }
From source file:net.sourceforge.fenixedu.util.tests.ResponseExternalization.java
private static Response getResponse(String xmlResponse) { XMLDecoder decoder = null;//from w w w. j a v a 2 s . c o m try { decoder = new XMLDecoder(new ByteArrayInputStream(xmlResponse.getBytes(CharEncoding.UTF_8))); } catch (UnsupportedEncodingException e1) { logger.error(e1.getMessage(), e1); } Response response = null; try { response = (Response) decoder.readObject(); } catch (ArrayIndexOutOfBoundsException e) { logger.error(e.getMessage(), e); } decoder.close(); return response; }
From source file:com.github.woki.payments.adyen.action.CSEUtil.java
static String encrypt(final Cipher aesCipher, final Cipher rsaCipher, final String plainText) throws BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException { SecretKey aesKey = aesKey(256); byte[] iv = iv(CSE_RANDOM, 12); aesCipher.init(Cipher.ENCRYPT_MODE, aesKey, new IvParameterSpec(iv)); byte[] encrypted = aesCipher.doFinal(plainText.getBytes()); byte[] result = new byte[iv.length + encrypted.length]; System.arraycopy(iv, 0, result, 0, iv.length); System.arraycopy(encrypted, 0, result, iv.length, encrypted.length); byte[] encryptedAESKey; try {/*from w w w.j a v a2 s .co m*/ encryptedAESKey = rsaCipher.doFinal(aesKey.getEncoded()); } catch (ArrayIndexOutOfBoundsException e) { throw new InvalidKeyException(e.getMessage()); } return String.format("%s%s%s%s%s%s", CSE_PREFIX, CSE_VERSION, CSE_SEPARATOR, Base64.encodeBase64String(encryptedAESKey), CSE_SEPARATOR, Base64.encodeBase64String(result)); }
From source file:org.springframework.shell.SimpleShellCommandLineOptions.java
public static SimpleShellCommandLineOptions parseCommandLine(String[] args) throws IOException { SimpleShellCommandLineOptions options = new SimpleShellCommandLineOptions(); List<String> commands = new ArrayList<String>(); int i = 0;/*from w ww . j a va2s. c om*/ while (i < args.length) { String arg = args[i++]; if (arg.equals("--profiles")) { try { String profiles = args[i++]; options.extraSystemProperties.put("spring.profiles.active", profiles); } catch (ArrayIndexOutOfBoundsException e) { LOGGER.warning("No value specified for --profiles option"); } } else if (arg.equals("--cmdfile")) { try { File f = new File(args[i++]); commands.addAll(FileUtils.readLines(f)); } catch (IOException e) { LOGGER.warning("Could not read lines from command file: " + e.getMessage()); } catch (ArrayIndexOutOfBoundsException e) { LOGGER.warning("No value specified for --cmdfile option"); } } else if (arg.equals("--histsize")) { try { String histSizeArg = args[i++]; int histSize = Integer.parseInt(histSizeArg); if (histSize <= 0) { LOGGER.warning( "histsize option must be > 0, using default value of " + DEFAULT_HISTORY_SIZE); } else { options.historySize = histSize; } } catch (NumberFormatException e) { LOGGER.warning("Unable to parse histsize value to an integer "); } catch (ArrayIndexOutOfBoundsException ae) { LOGGER.warning("No value specified for --histsize option"); } } else if (arg.equals("--help")) { printUsage(); System.exit(0); } else { i--; break; } } StringBuilder sb = new StringBuilder(); for (; i < args.length; i++) { if (sb.length() > 0) { sb.append(" "); } sb.append(args[i]); } if (sb.length() > 0) { String[] cmdLineCommands = sb.toString().split(";"); for (String s : cmdLineCommands) { //add any command line commands after the commands loaded from the file commands.add(s.trim()); } } if (commands.size() > 0) options.executeThenQuit = commands.toArray(new String[commands.size()]); return options; }
From source file:controllers.nwbib.Lobid.java
private static void mapIsilsToUris(JsonNode items, Map<String, List<String>> result) { Iterator<JsonNode> elements = items.isArray() ? items.elements() : Arrays.asList(items).iterator(); while (elements.hasNext()) { String itemUri = elements.next().asText(); try {//from w w w .jav a2s .com String isil = itemUri.split(":")[2]; List<String> uris = result.getOrDefault(isil, new ArrayList<>()); uris.add(itemUri); result.put(isil, uris); } catch (ArrayIndexOutOfBoundsException x) { Logger.error(x.getMessage()); } } }
From source file:edu.cuhk.hccl.TripAdvisorApp.java
@Override public StringBuilder processStream(String fileName) throws FileNotFoundException, IOException { StringBuilder result = new StringBuilder(); List<String> lines = FileUtils.readLines(new File(fileName), "UTF-8"); String hotelID = fileName.split("_")[1]; String author = null;//from w w w . j a v a 2 s .c om String review = null; String[] rates = null; for (String line : lines) { boolean recordEnd = false; try { if (line.startsWith("<Author>")) { author = line.split(">")[1].trim(); } else if (line.startsWith("<Content>")) { review = line.split(">")[1].trim(); if (review.isEmpty()) continue; } else if (line.startsWith("<Rating>")) { rates = line.split(">")[1].trim().split("\t"); // Change missing rating from -1 to 0 for (int i = 0; i < rates.length; i++) { if (rates[i].equals("-1")) rates[i] = "0"; } recordEnd = true; } } catch (ArrayIndexOutOfBoundsException e) { System.out.print(e.getMessage()); continue; } if (recordEnd) { ArrayList<String> selectedPhrase = DatasetUtil.processRecord(hotelID, result, review, author, rates, Constant.TRIPADVISOR_ASPECTS, 2); for (String phrase : selectedPhrase) { FileUtils.writeStringToFile(phraseFile, phrase + "\n", true); } } } return result; }
From source file:ListOfNumbers2.java
public void writeList() { PrintWriter out = null;// w ww. j a va 2 s .co m try { out = new PrintWriter(new FileWriter("outfile.txt")); for (int i = 0; i < victor.size(); i++) out.println("Value at: " + i + " = " + victor.elementAt(i)); } catch (ArrayIndexOutOfBoundsException e) { System.err.println("Caught ArrayIndexOutOfBoundsException: " + e.getMessage()); } catch (IOException e) { System.err.println("Caught IOException: " + e.getMessage()); } finally { if (out != null) { System.out.println("Closing PrintWriter"); out.close(); } else { System.out.println("PrintWriter not open"); } } }
From source file:org.apache.bookkeeper.util.HexDumpEntryFormatter.java
@Override public void formatEntry(byte[] data) { try {//from www . java 2 s.com HexDump.dump(data, 0, System.out, 0); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Warn: Index is outside the data array's bounds : " + e.getMessage()); } catch (IllegalArgumentException e) { System.out.println("Warn: The output stream is null : " + e.getMessage()); } catch (IOException e) { System.out.println("Warn: Something has gone wrong writing the data to stream : " + e.getMessage()); } }
From source file:ListOfNumbers.java
public void writeList() { PrintWriter out = null;//w w w . ja va2s . c o m try { System.out.println("Entering try statement"); out = new PrintWriter(new FileWriter("OutFile.txt")); for (int i = 0; i < SIZE; i++) out.println("Value at: " + i + " = " + victor.elementAt(i)); } catch (ArrayIndexOutOfBoundsException e) { System.err.println("Caught ArrayIndexOutOfBoundsException: " + e.getMessage()); } catch (IOException e) { System.err.println("Caught IOException: " + e.getMessage()); } finally { if (out != null) { System.out.println("Closing PrintWriter"); out.close(); } else { System.out.println("PrintWriter not open"); } } }