List of usage examples for java.lang System arraycopy
@HotSpotIntrinsicCandidate public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
From source file:com.lightboxtechnologies.spectrum.MRCoffeeJob.java
public static void main(String[] args) throws ClassNotFoundException, DecoderException, IOException, InterruptedException { final Configuration conf = HBaseConfiguration.create(); final String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if (otherArgs.length < 3) { System.err.println("Usage: MRCoffeeJob <image_id> <outpath> <command>..."); System.exit(2);// w w w .j a v a 2 s .c o m } // get command and arguments final String[] command = new String[otherArgs.length - 2]; System.arraycopy(args, 2, command, 0, command.length); System.exit(run(args[0], args[1], command, conf)); }
From source file:com.microsoft.gittf.client.clc.Main.java
public static void main(String[] args) { // Configure logging, use the standard TFS SDK logging. System.setProperty("teamexplorer.application", ProductInformation.getProductName()); //$NON-NLS-1$ LoggingConfiguration.configure();//w w w .java 2 s .c om final Log log = LogFactory.getLog(ProductInformation.getProductName()); try { ArgumentCollection mainArguments = new ArgumentCollection(); try { mainArguments = ArgumentParser.parse(args, ARGUMENTS, ArgumentParserOptions.ALLOW_UNKNOWN_ARGUMENTS); } catch (ArgumentParserException e) { console.getErrorStream().println(e.getLocalizedMessage()); console.getErrorStream().println(getUsage()); System.exit(ExitCode.FAILURE); } if (mainArguments.contains("version")) //$NON-NLS-1$ { console.getOutputStream().println(Messages.formatString("Main.ApplicationVersionFormat", //$NON-NLS-1$ ProductInformation.getProductName(), ProductInformation.getBuildNumber())); return; } /* * Special case "--help command" handling - convert to * "help command" */ if (mainArguments.contains("help") && mainArguments.contains("command")) //$NON-NLS-1$ //$NON-NLS-2$ { HelpCommand helpCommand = new HelpCommand(); helpCommand.setArguments(ArgumentParser.parse(new String[] { ((FreeArgumentCollection) mainArguments.getArgument("command")).getValues()[0] //$NON-NLS-1$ }, helpCommand.getPossibleArguments())); helpCommand.setConsole(console); helpCommand.run(); return; } else if (mainArguments.contains("help") || !mainArguments.contains("command")) //$NON-NLS-1$ //$NON-NLS-2$ { showHelp(); return; } // Set the verbosity of the console from the arguments. if (mainArguments.contains("quiet")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.QUIET); } else if (mainArguments.contains("verbose")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.VERBOSE); } /* * Parse the free arguments into the command name and arguments to * pass to it. Add any unmatched arguments that were specified on * the command line before the argument. (eg, for * "git-tf --bare clone", we parsed the "--bare" as an unmatched * argument to the main command. We instead want to add the "--bare" * as an argument to "clone".) */ String[] fullCommand = ((FreeArgumentCollection) mainArguments.getArgument("command")).getValues(); //$NON-NLS-1$ String[] additionalArguments = mainArguments.getUnknownArguments(); String commandName = fullCommand[0]; String[] commandArgs = new String[additionalArguments.length + (fullCommand.length - 1)]; if (additionalArguments.length > 0) { System.arraycopy(additionalArguments, 0, commandArgs, 0, additionalArguments.length); } if (fullCommand.length > 1) { System.arraycopy(fullCommand, 1, commandArgs, mainArguments.getUnknownArguments().length, fullCommand.length - 1); } // Locate the specified command by name List<CommandDefinition> possibleCommands = new ArrayList<CommandDefinition>(); for (CommandDefinition c : COMMANDS) { if (c.getName().equals(commandName)) { possibleCommands.clear(); possibleCommands.add(c); break; } else if (c.getName().startsWith(commandName)) { possibleCommands.add(c); } } if (possibleCommands.size() == 0) { printError(Messages.formatString("Main.CommandNotFoundFormat", commandName, //$NON-NLS-1$ ProductInformation.getProductName())); System.exit(1); } if (possibleCommands.size() > 1) { printError(Messages.formatString("Main.AmbiguousCommandFormat", commandName, //$NON-NLS-1$ ProductInformation.getProductName())); for (CommandDefinition c : possibleCommands) { printError(Messages.formatString("Main.AmbiguousCommandListFormat", c.getName()), false); //$NON-NLS-1$ } System.exit(1); } // Instantiate the command final CommandDefinition commandDefinition = possibleCommands.get(0); Command command = null; try { command = commandDefinition.getType().newInstance(); } catch (Exception e) { printError(Messages.formatString("Main.CommandCreationFailedFormat", commandName)); //$NON-NLS-1$ System.exit(1); } // Set the console command.setConsole(console); // Parse the arguments ArgumentCollection argumentCollection = null; try { argumentCollection = ArgumentParser.parse(commandArgs, command.getPossibleArguments()); } catch (ArgumentParserException e) { Main.printError(e.getLocalizedMessage()); Main.printError(getUsage(command)); log.error("Could not parse arguments", e); //$NON-NLS-1$ System.exit(1); } // Handle the --help argument directly if (argumentCollection.contains("help")) //$NON-NLS-1$ { command.showHelp(); System.exit(0); } // Set the verbosity of the console from the arguments. if (argumentCollection.contains("quiet")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.QUIET); } else if (argumentCollection.contains("verbose")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.VERBOSE); } command.setArguments(argumentCollection); System.exit(command.run()); } catch (Exception e) { printError(e.getLocalizedMessage()); log.warn(MessageFormat.format("Error executing command: {0}", getCommandLine(args)), e); //$NON-NLS-1$ } }
From source file:Main.java
public static int[] arrayintexpend(int[] array, int increment) { System.arraycopy(array, 0, array = new int[array.length + increment], 0, array.length - increment); return array; }
From source file:Main.java
public static byte[] arraybyteexpend(byte[] array, int increment) { System.arraycopy(array, 0, array = new byte[array.length + increment], 0, array.length - increment); return array; }
From source file:Main.java
public static String getString(byte[] dest, byte[] bytes, int srcPos, int length) { System.arraycopy(bytes, srcPos, dest, 0, length); return new String(dest); }
From source file:Main.java
public static byte[] substring(byte[] a, int start, int len) { byte[] rval = new byte[len]; System.arraycopy(a, start, rval, 0, len); return rval;// w ww.j ava 2 s . c o m }
From source file:Main.java
public static byte[] cloneByteArray(byte[] a) { byte[] result = new byte[a.length]; System.arraycopy(a, 0, result, 0, a.length); return result; }
From source file:Main.java
static public int[] grow(int A[], int amount) { int B[] = new int[A.length + amount]; System.arraycopy(A, 0, B, 0, A.length); return B;/*w w w.java 2 s . c o m*/ }
From source file:Main.java
private static float[] copyMatrix(float[] matrix) { float[] copyM = new float[matrix.length]; System.arraycopy(matrix, 0, copyM, 0, matrix.length); return copyM; }
From source file:Main.java
public static byte[] concat(byte[] A, byte[] B) { byte[] C = new byte[A.length + B.length]; System.arraycopy(A, 0, C, 0, A.length); System.arraycopy(B, 0, C, A.length, B.length); return C;/* w ww . ja v a2 s . c om*/ }