获取多个数字的最小公倍数

@param arg
@return
@throws Exception
540413
public static int getLCM(int... arg) throws Exception {
        if (arg == null || arg.length == 0) {
            throw new Exception("parameters must more than one.");
        }
        if (arg.length == 1)
            return arg[0];

        int tmp = lcm(arg[0], arg[1]);

        for (int i = 2; i < arg.length; i++) {
            tmp = lcm(tmp, arg[i]);
        }

        return tmp;
    }
608046
private int init(String[] args) {
    try {
      for (int i = 0; i < args.length; i++) { // parse command line
        if (args[i].equals("-maxDepth")) {
          maxDepth = Integer.parseInt(args[++i]);
          if (maxDepth<1) {
            System.err.println("maxDepth must be positive: " + maxDepth);
            return -1;
          }
        } else if (args[i].equals("-minWidth")) {
          minWidth = Integer.parseInt(args[++i]);
          if (minWidth<0) {
            System.err.println("minWidth must be positive: " + minWidth);
            return -1;
          }
        } else if (args[i].equals("-maxWidth")) {
          maxWidth = Integer.parseInt(args[++i]);
        } else if (args[i].equals("-numOfFiles")) {
          numOfFiles = Integer.parseInt(args[++i]);
          if (numOfFiles<1) {
            System.err.println("NumOfFiles must be positive: " + numOfFiles);
            return -1;
          }
        } else if (args[i].equals("-avgFileSize")) {
          avgFileSize = Double.parseDouble(args[++i]);
          if (avgFileSize<=0) {
            System.err.println("AvgFileSize must be positive: " + avgFileSize);
            return -1;
          }
        } else if (args[i].equals("-outDir")) {
          outDir = new File(args[++i]);
        } else if (args[i].equals("-seed")) {
          r = new Random(Long.parseLong(args[++i]));
        } else {
          System.err.println(USAGE);
          ToolRunner.printGenericCommandUsage(System.err);
          return -1;
        }
      }
    } catch (NumberFormatException e) {
      System.err.println("Illegal parameter: " + e.getLocalizedMessage());
      System.err.println(USAGE);
      return -1;
    }

    if (maxWidth < minWidth) {
      System.err.println(
          "maxWidth must be bigger than minWidth: " + maxWidth);
      return -1;
    }

    if (r==null) {
      r = new Random();
    }
    return 0;
  }
71484
public static void main(String[] args)
	{
		try
		{
			if (args.length == 0)
			{

				System.err.println("Usage java " + Cryption.class.getName()
				+ " <text>");
				return;

			}

			final String decryptedPassword;

			if (args[0].equals("-d"))
			{
				if (args.length > 2)
				{
					StringBuilder p = new StringBuilder();
					for (int i = 1; i < args.length; i++)
					{
						if (i > 1)
							p.append(' ');

						p.append(args[i]);
					}

					decryptedPassword = p.toString();
				}
				else
				{
					decryptedPassword = args[1];
				}

				System.out.println(getCanonical().decryptText(decryptedPassword));
			}
			else
				System.out.println(CRYPTION_PREFIX
				+ getCanonical().encryptText(args[0]));

		}
		catch (Exception e)
		{

			e.printStackTrace();
		}

	}
1298307
public static int execute(String... args) {
        Start jdoc = new Start();
        return jdoc.begin(args).exitCode;
    }
797392
public static void main(String[] args) throws Exception {
        OptionParser parser = null;
        OptionSet options = null;
        try {
            parser = getParser();
            options = parser.parse(args);
        } catch(OptionException oe) {
            parser.printHelpOn(System.out);
            printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
            return;
        }

        /* validate options */
        if(options.has("help")) {
            parser.printHelpOn(System.out);
            printUsage();
            return;
        }
        if(!options.hasArgument("url") || !options.hasArgument("in-dir")
           || !options.hasArgument("out-dir")) {
            parser.printHelpOn(System.out);
            printUsageAndDie("Missing a required argument.");
            return;
        }

        String url = (String) options.valueOf("url");

        String inDir = (String) options.valueOf("in-dir");
        Utils.mkdirs(new File(inDir));

        String outDir = (String) options.valueOf("out-dir");
        Utils.mkdirs(new File(outDir));

        List<String> storeNames = null;
        if(options.hasArgument("store-names")) {
            @SuppressWarnings("unchecked")
            List<String> list = (List<String>) options.valuesOf("store-names");
            storeNames = list;
        }

        Integer keyParallelism = DEFAULT_KEY_PARALLELISM;
        if(options.hasArgument("parallelism")) {
            keyParallelism = (Integer) options.valueOf("parallelism");
        }

        Integer progressPeriodOps = DEFAULT_PROGRESS_PERIOD_OPS;
        if(options.hasArgument("progress-period-ops")) {
            progressPeriodOps = (Integer) options.valueOf("progress-period-ops");
        }

        Integer outputBatchSize = DEFAULT_OUTPUT_BATCH_SIZE;
        if(options.hasArgument("output-batch-size")) {
            outputBatchSize = (Integer) options.valueOf("output-batch-size");
        }

        boolean details = options.has("details");

        try {
            KeyVersionFetcherCLI sampler = new KeyVersionFetcherCLI(url,
                                                                    inDir,
                                                                    outDir,
                                                                    storeNames,
                                                                    keyParallelism,
                                                                    progressPeriodOps,
                                                                    outputBatchSize,
                                                                    details);

            try {
                if(!sampler.sampleStores()) {
                    logger.error("Key-versions were not successfully sampled from some stores.");
                }
            } finally {
                sampler.stop();
            }

        } catch(Exception e) {
            logger.error("Exception during key-version sampling: ", e);
        }
    }
1124268
@Configurable
  public void addArg(String arg)
  {
    if (_args == null)
      _args = new ArrayList<String>();
    
    _args.add(arg);
  }
861026
public Object execEval(String arg) {
		try {
			return scriptEngine.eval("eval(" + arg + ")");
		} catch (ScriptException e) {
			throw new BundlingProcessException("Error while evaluating a script", e);
		}
	}
330204
public static void main(String[] args) throws Exception {
        EncryptionUtil util = new EncryptionUtil();

        System.out.println("Enter text to encrypt: ");
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input = reader.readLine();
        if (null != input && !"".equals(input)) {
            System.out.println("'" + util.encrypt(input) + "'");
        }
    }
642010
public static void executeCommand(String[] args) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = AdminToolUtils.copyArrayCutFirst(args);
        if(subCmd.equals("get")) {
            SubCommandQuotaGet.executeCommand(args);
        } else if(subCmd.equals("set")) {
            SubCommandQuotaSet.executeCommand(args);
        } else if(subCmd.equals("reserve-memory")) {
            SubCommandQuotaReserveMemory.executeCommand(args);
        } else if(subCmd.equals("unset")) {
            SubCommandQuotaUnset.executeCommand(args);
        } else {
            printHelp(System.out);
        }
    }
143231
public static void main(String[] args) throws Exception {
		String originalValue = "Amman123";
		byte[] encryptedValue = encrypt(originalValue.getBytes());
		String descryptedValue = new String(decrypt(encryptedValue), "UTF-8");
		byte[] hashed = hash(originalValue.toCharArray(), salt());

		System.out.println("Original value: " + originalValue);
		System.out.println("Encrypted value: " + new String(encryptedValue));
		System.out.println("Decryped value: " + descryptedValue);

		System.out.println("Hashing original value:" + encodeInToBase64(hashed));

		Password password = createPassword(originalValue.toCharArray());
		System.out.println("Password hash: " + password.getHash());
		System.out.println("Password salt: " + password.getSalt());
//		System.out.println(encode("3"));

	}
1260102
public static void main(String[] args) throws Exception {

        // Generate public/private key pair
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
        keyGen.initialize(2048);
        KeyPair pair = keyGen.generateKeyPair();
        java.security.PublicKey pk = pair.getPublic();

        // Use the default rest client
        TwilioRestClient client =
            new TwilioRestClient.Builder(ACCOUNT_SID, AUTH_TOKEN)
                .build();

        // Create a public key and signing key using the default client
        PublicKey key = PublicKey.creator(
            Base64.encodeBase64String(pk.getEncoded())
        ).setFriendlyName("Public Key").create(client);

        NewSigningKey signingKey = NewSigningKey.creator().create(client);

        // Switch to validation client as the default client
        TwilioRestClient validationClient = new TwilioRestClient.Builder(signingKey.getSid(), signingKey.getSecret())
            .accountSid(ACCOUNT_SID)
            .httpClient(new ValidationClient(ACCOUNT_SID, key.getSid(), signingKey.getSid(), pair.getPrivate()))
            .build();

        // Make REST API requests
        Iterable<Message> messages = Message.reader().read(validationClient);
        for (Message message : messages) {
            System.out.println(message.getBody());
        }

        Message message = Message.creator(
            new PhoneNumber("+1XXXXXXXXXX"),
            new PhoneNumber("+1XXXXXXXXXX"),
            "Public Key Client Validation Test"
        ).create(validationClient);
        System.out.println(message.getSid());
    }
1266649
public static void main(String[] args) throws Exception {

		String datapath = "../data";
		
		
		String allfile = datapath + "/FNLPDATA/all.seg";	
		String testfile = datapath + "/FNLPDATA/test.seg";	
		String trainfile = datapath + "/FNLPDATA/train.seg";
		MyFiles.delete(testfile);
		MyFiles.delete(trainfile);
		MyFiles.delete(allfile);

		String dictfile = datapath + "/FNLPDATA/dict.seg";

		String segfile = datapath + "/FNLPDATA/temp.seg";
		//清理
		MyFiles.delete(dictfile);
		MyFiles.delete(segfile);
		

		FNLPCorpus corpus = new FNLPCorpus();
		//读自有数据
		corpus.readOurCorpus(datapath + "/ourdata",".txt","UTF8");
		//读分词文件
		corpus.readCWS(datapath + "/FNLPDATA/seg",".txt","UTF8");	
		//读分词+词性文件
		corpus.readPOS(datapath + "/FNLPDATA/pos",".txt","UTF8");	
		//读FNLP数据
		corpus.read(datapath + "/FNLPDATA/ctb7.dat", null);			
		corpus.read(datapath + "/FNLPDATA/WeiboFTB(v1.0)-train.dat", null);



		FNLP2BMES.w2BMES(corpus,segfile);		
		//FNLP2BMES.w2BMES(corpus,segfile_w); //?


		//词典转BMES
		//搜狗词典
		DICT dict = new DICT();
		String sougou = datapath + "/FNLPDATA/dict/SogouLabDic.dic.raw";

//		dict.readSougou(sougou,2,3,"sougou");
		//互动词典
		String hudong = datapath + "/FNLPDATA/dict/hudong.dic.all";
//		dict.readSougou(hudong,2,3,"");
		//添加其他词典
		dict.readDictionary(datapath + "/FNLPDATA/dict",".dic");

		//添加其他词典
//		dict.readDictionaryWithFrequency(datapath + "/FNLPDATA/dict",".dic.freq");




		//添加词性字典
		dict.readPOSDICT(datapath + "/FNLPDATA/词性字典", ".txt");
		dict.readPOSDICT(datapath + "/FNLPDATA/dict-sogou-input/txt", ".txt");

		dict.toBMES(dictfile,3);
		new File(dictfile).deleteOnExit();

		//合并训练文件
		
		
		
		List<File> files = MyFiles.getAllFiles(datapath + "/FNLPDATA/", ".seg");
		MyFiles.combine(trainfile,files.toArray(new File[files.size()]));
		
		//生成新字典		
		String dicfile = datapath + "/FNLPDATA/train.dict";
		DICT.BMES2DICT(trainfile,dicfile);

		//处理测试数据
		FNLPCorpus corpust = new FNLPCorpus();
		//读自有数据
		corpust.read(datapath + "/FNLPDATA/WeiboFTB(v1.0)-test.dat", null);	
		
		FNLP2BMES.w2BMES(corpust,testfile);		
		
		


		System.out.println(new Date().toString());
		System.out.println("Done!");




	}
1220516
@Override
  public int run(String[] argv) throws Exception {
    int exitCode = 0;

    Options options = buildOptions();
    if(argv.length == 0) {
      printHelp();
      return -1;
    }

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;

    try {
      cmd = parser.parse(options, argv);
    } catch (ParseException e) {
      System.out.println(
        "Error parsing command-line options: " + e.getMessage());
      printHelp();
      return -1;
    }

    if(cmd.hasOption("h")) { // print help and exit
      printHelp();
      return -1;
    }

    boolean printToScreen    = false;
    String inputFilenameArg  = cmd.getOptionValue("i");
    String outputFilenameArg = cmd.getOptionValue("o");
    String processor         = cmd.getOptionValue("p");
    if(processor == null) { processor = defaultProcessor; }

    if(cmd.hasOption("v")) { // print output to screen too
      printToScreen = true;
      System.out.println("input  [" + inputFilenameArg  + "]");
      System.out.println("output [" + outputFilenameArg + "]");
    }

    try {
      go(EditsVisitorFactory.getEditsVisitor(
        outputFilenameArg,
        processor,
        TokenizerFactory.getTokenizer(inputFilenameArg),
        printToScreen));
    } catch (EOFException e) {
      System.err.println("Input file ended unexpectedly. Exiting");
      exitCode = 255;
    } catch(IOException e) {
      System.err.println("Encountered exception. Exiting: " + e.getMessage());
      exitCode = 1;
    }

    return exitCode;
  }
300867
public static String trim(String str, String arg) {
        if (str == null || arg == null) {
            throw new NullPointerException("str or arg must not be null");
        }

        while (str.startsWith(arg)) {
            str = str.substring(arg.length());
        }

        while (str.endsWith(arg)) {
            str = str.substring(0, str.length() - arg.length());
        }
        return str;
    }
792264
public static void main(String[] arg)
    {
        try
        {
            for (int i = 0; i < arg.length; i++)
                new XmlConfiguration(Resource.newResource(arg[i]).getURL()).newInstance();
        }
        catch (Exception e)
        {
            log.warn(LogSupport.EXCEPTION, e);
        }
    }
156328
public static void main(String[] args) throws Exception {
		
		NERTagger tag = new NERTagger("../models/seg.m","../models/pos.m");
		String str = " 新浪体育讯　北京时间4月15日03:00(英国当地时间14日20:00)，2009/10赛季英格兰足球超级联赛第34轮一场焦点战在白鹿巷球场展开角逐，阿森纳客场1比2不敌托特纳姆热刺，丹尼-罗斯和拜尔先入两球，本特纳扳回一城。阿森纳仍落后切尔西6分(净胜球少15个)，夺冠几成泡影。热刺近 7轮联赛取得6胜，继续以1分之差紧逼曼城。";
		HashMap<String, String> map = new HashMap<String, String>();
		tag.tag(str,map);
		System.out.println(map);
		map = tag.tagFile("../example-data/data-tag.txt");
		System.out.println(map);
		System.out.println("Done!");
	}
1300898
public static <T> T newInstanceWithArgs(Class<T> clazz, Class<?>[] argTypes, Object[] args)
        throws SofaRpcRuntimeException {
        if (CommonUtils.isEmpty(argTypes)) {
            return newInstance(clazz);
        }
        try {
            if (!(clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()))) {
                Constructor<T> constructor = clazz.getDeclaredConstructor(argTypes);
                constructor.setAccessible(true);
                return constructor.newInstance(args);
            } else {
                Constructor<T>[] constructors = (Constructor<T>[]) clazz.getDeclaredConstructors();
                if (constructors == null || constructors.length == 0) {
                    throw new SofaRpcRuntimeException("The " + clazz.getCanonicalName()
                        + " has no constructor with argTypes :" + Arrays.toString(argTypes));
                }
                Constructor<T> constructor = null;
                for (Constructor<T> c : constructors) {
                    Class[] ps = c.getParameterTypes();
                    if (ps.length == argTypes.length + 1) { // 长度多一
                        boolean allMath = true;
                        for (int i = 1; i < ps.length; i++) { // 而且第二个开始的参数类型匹配
                            if (ps[i] != argTypes[i - 1]) {
                                allMath = false;
                                break;
                            }
                        }
                        if (allMath) {
                            constructor = c;
                            break;
                        }
                    }
                }
                if (constructor == null) {
                    throw new SofaRpcRuntimeException("The " + clazz.getCanonicalName()
                        + " has no constructor with argTypes :" + Arrays.toString(argTypes));
                } else {
                    constructor.setAccessible(true);
                    Object[] newArgs = new Object[args.length + 1];
                    System.arraycopy(args, 0, newArgs, 1, args.length);
                    return constructor.newInstance(newArgs);
                }
            }
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Throwable e) {
            throw new SofaRpcRuntimeException(e.getMessage(), e);
        }
    }