public static void main(String[] ARGS) { double latitude = 0; double longitude = 0; if (ARGS.length < 2) { System.out.println("Usage: GridConverter <latitude> <longitude>"); System.exit(1); } try { latitude = Double.parseDouble(ARGS[0]); longitude = Double.parseDouble(ARGS[1]); } catch (NumberFormatException nfe) { System.err.println("Please check your number formats."); System.exit(1); } latitude = 41.7146; longitude = -72.7271; System.out.println(" Converting " + longitude + ", " + latitude); double olong = 180.0 + longitude; double olat = 90.0 + latitude; System.out.println(olong + " " + olat); int fieldLongitude = (int) (Math.floor(olong / 20.0)); int fieldLatitude = (int) (Math.floor(olat / 10.0)); System.out.println(fieldLongitude + " " + fieldLatitude); char field1 = field[fieldLongitude]; char field2 = field[fieldLatitude]; double degreesFromEasting = olong - (fieldLongitude * 20); double degreesFromNorthing = olat - (fieldLatitude * 10); System.out.println(degreesFromEasting + " " + degreesFromNorthing); int squareLongitude = (int) Math.floor(degreesFromEasting / 2); int squareLatitude = (int) Math.floor(degreesFromNorthing); System.out.println(field1 + "" + field2 + "" + squareLongitude + "" + squareLatitude); }
public static void main(String[] args) throws IOException, ClassNotFoundException { ServerSocket serverSocket = null; boolean listening = true; Class.forName("org.sqlite.JDBC"); try { if (args.length == 1) { serverSocket = new ServerSocket(Integer.parseInt(args[0])); System.out.println( "Server up and running with:\nhostname: " + getLocalIpAddress() + "\nport: " + args[0]); System.out.println("Waiting to accept client..."); System.out.println("Remember to setup client hostname"); } else { System.err.println("ERROR: Invalid arguments!"); System.exit(-1); } } catch (IOException e) { System.err.println("ERROR: Could not listen on port!"); System.exit(-1); } while (listening) { new ServerHandlerThread(serverSocket.accept()).start(); } serverSocket.close(); }
public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(10008); System.out.println("Enroll: 130050131071"); System.out.println("Connection Socket Created"); try { while (true) { System.out.println("Waiting for Connection"); new EchoServer2(serverSocket.accept()); } } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } } catch (IOException e) { System.err.println("Could not listen on port: 10008."); System.exit(1); } finally { try { serverSocket.close(); } catch (IOException e) { System.err.println("Could not close port: 10008."); System.exit(1); } } }
/** * creates a server socket listening on the port specified in the parameter of the constructor, * and waits for a single incoming client connection which it handles by invoking the <CODE> * addNewClientConnection(s)</CODE> method of the enclosing server, and then the thread exits. */ public void run() { try { ServerSocket ss = new ServerSocket(_port); System.out.println("Srv: Now Accepting Single Client Connection"); // while (true) { try { Socket s = ss.accept(); System.out.println("Srv: Client Added to the Network"); addNewClientConnection(s); System.out.println("Srv: finished adding client connection"); } catch (Exception e) { // e.printStackTrace(); System.err.println("Client Connection failed, exiting..."); System.exit(-1); } // } } catch (IOException e) { // e.printStackTrace(); utils.Messenger.getInstance() .msg( "PDBTExecSingleCltWrkInitSrv.C2Thread.run(): " + "Failed to create Server Socket, Server exiting.", 0); System.exit(-1); } }
private static void join() { System.out.println("Joining server group..."); Properties newRMIconfig = localServer.getRmiSettings(); findActive(); if (remoteServer != null) { try { String tempselfName = remoteServer.serverJoin(newRMIconfig.getProperty("publicIP")); if (tempselfName != null) { selfName = tempselfName; newRMIconfig.setProperty("name", selfName); try { PropertyHandler.save(RMI_CONFIG_FILE, newRMIconfig); init(); } catch (Exception ex) { System.out.println("save rmiserver config failed"); } System.out.println("You have joined the server group of " + remoteServer.getServerName()); } else { System.out.println("you are already in the group of " + remoteServer.getServerName()); } } catch (RemoteException ex) { System.out.println("no active server"); System.exit(1); } startClientMode(); } else { System.out.println("no active server"); System.exit(1); } }
public void run(String[] args) { String script = null; try { FileInputStream stream = new FileInputStream(new File(args[0])); try { FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); script = Charset.availableCharsets().get("UTF-8").decode(bb).toString(); } finally { stream.close(); } } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } Context cx = Context.enter(); try { ScriptableObject scope = cx.initStandardObjects(); scope.putConst("language", scope, "java"); scope.putConst("platform", scope, "android"); scope.put("util", scope, new Util(cx, scope)); cx.evaluateString(scope, script, args[0], 1, null); } catch (Error ex) { ex.printStackTrace(); System.exit(1); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } finally { Context.exit(); } System.exit(0); }
/** * Uses {@link uk.ac.aber.cs211.wordladder.Generator} to produce a random word ladder. args[1] is * the initial word while args[2] is the depth of the word ladder to produce. * * @param args Command line arguments from invocation. */ public static void generate(String[] args) { String startWord = null; int depth = 0; try { startWord = args[1]; depth = Integer.parseInt(args[2]); } catch (NullPointerException e) { if (args.length < 3) { System.err.println("Insufficient arguments."); printHelp(); System.exit(-1); } e.printStackTrace(); System.exit(-1); } Generator generator = null; try { generator = new Generator().setStart(startWord).setDepth(depth); } catch (IOException e) { System.err.println("Could not load dictionaries. Check current working directory."); System.exit(-1); } List<String> solution = generator.run(); if (solution == null) { System.err.println("A ladder of that depth is not possible."); System.exit(-1); } System.out.println(solution); System.exit(0); }
/** * Program entry point. * * @param args program arguments */ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // input/out File input = new File(VisibilityCircle.class.getResource("/visibility-circle.in").toURI().getPath()); File output = new File(input.getParentFile(), "visibility-circle.csv"); new VisibilityCircle().run(input, output, ","); System.out.println("visibility circle saved as file " + output); } catch (URISyntaxException use) { System.err.println(use.getLocalizedMessage()); System.exit(1); } catch (IOException ioe) { System.err.println(ioe.getLocalizedMessage()); System.exit(1); } catch (IllegalArgumentException iae) { System.err.println(iae.getLocalizedMessage()); System.exit(1); } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); } }
// ---- main ---- public static void main(final String[] argv) { if (argv.length != 1) { System.err.println( "Usage: java " + GpxReader.class.getSimpleName() + " <file>"); //$NON-NLS-1$ //$NON-NLS-2$ System.exit(1); } final long startMillis = System.currentTimeMillis(); try { final File f = new File(argv[0]); System.out.println("File size: " + f.length() + " bytes"); // $NON-NLS-1$ //$NON-NLS-2$ // Use an instance of ourselves as the SAX event handler final DefaultHandler handler = new GpxReader(); // Parse the input with the default (non-validating) parser final SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); saxParser.parse(f, handler); } catch (final Exception t) { t.printStackTrace(); System.exit(2); } final long millis = System.currentTimeMillis() - startMillis; System.out.println("Time consumed: " + millis + " ms"); // $NON-NLS-1$ //$NON-NLS-2$ }
/** * Entry point. * * @param args Command line arguments. */ public static void main(String[] args) { final Resources resources = new ResourcesImplementation("net.grinder.console.common.resources.Console"); final Logger logger = new SimpleLogger( resources.getString("shortTitle"), new PrintWriter(System.out), new PrintWriter(System.err)); try { final Console console = new Console(args, resources, logger); console.run(); } catch (LoggedInitialisationException e) { System.exit(1); } catch (GrinderException e) { logger.error("Could not initialise:"); final PrintWriter errorWriter = logger.getErrorLogWriter(); e.printStackTrace(errorWriter); errorWriter.flush(); System.exit(2); } System.exit(0); }
public void listenSocket() { try { server = new ServerSocket(4321, 1, new InetSocketAddress(0).getAddress()); System.out.println( "Server is listening on " + server.getInetAddress().getHostName() + ":" + 4321); } catch (IOException e) { System.out.println("Could not listen on port 4321"); System.exit(-1); } try { client = server.accept(); System.out.println("Client connected on port " + 4321); has_client = true; } catch (IOException e) { System.out.println("Accept failed: 4321"); System.exit(-1); } try { in = new BufferedReader(new InputStreamReader(client.getInputStream())); out = new PrintWriter(client.getOutputStream(), true); } catch (IOException e) { System.out.println("Read failed"); System.exit(-1); } }
/** * Terminates with one of the following codes 1 A newer (or same version) jar file is already * installed 0 No newer jar file was found -1 An internal error occurred */ public static void main(String args[]) { if (args.length < 1) { System.err.println("Usage: extcheck [-verbose] <jar file>"); System.exit(-1); } int argIndex = 0; boolean verboseFlag = false; if (args[argIndex].equals("-verbose")) { verboseFlag = true; argIndex++; } String jarName = args[argIndex]; argIndex++; File jarFile = new File(jarName); if (!jarFile.exists()) { ExtCheck.error("Jarfile " + jarName + " does not exist"); } if (argIndex < args.length) { ExtCheck.error("Extra command line argument :" + args[argIndex]); } ExtCheck jt = ExtCheck.create(jarFile, verboseFlag); boolean result = jt.checkInstalledAgainstTarget(); if (result) { System.exit(0); } else { System.exit(1); } }
/** * Entry point. --rootDir is the optional parameter. * * @param args */ public static void main(String[] args) { try { String rootDirPath = "."; // try to read argument if (args.length == 1) { if (args[0].startsWith(GeneratorUtils.ROOT_DIR_PARAMETER)) { rootDirPath = args[0].substring(GeneratorUtils.ROOT_DIR_PARAMETER.length()); } else { System.err.print( "Wrong usage. There is only one allowed argument : " + GeneratorUtils.ROOT_DIR_PARAMETER); // NOSONAR System.exit(1); // NOSONAR } } File rootFolder = new File(rootDirPath); System.out.println( " ------------------------------------------------------------------------ "); System.out.println(String.format("Searching for DTO")); System.out.println( " ------------------------------------------------------------------------ "); // find all DtoFactoryVisitors findDtoFactoryVisitors(); generateExtensionManager(rootFolder); } catch (IOException e) { System.err.println(e.getMessage()); // error System.exit(1); // NOSONAR } }
public void run(String[] args) { File inDir = new File("input/SampleZoomLevel"); File outFile = new File("output/SampleZoomLevel/map.png"); File[] fileList = inDir.listFiles(); int i; // Stitching a map with 4 rows and 4 columns; the program is generalized, // so you can use higher multiples of 4, such as 8 by 8 and 16 by 16. int rows = 4; int cols = 4; int total = rows * cols; BufferedImage images[] = new BufferedImage[total]; try { for (i = 0; i < total; i++) { File inFile = fileList[i]; int c1; int c2; // The code below deals with the naming convention we use // for each map tile. // See the ReadMe for more on the naming convention. String s = inFile.getName().substring(0, 2); c1 = Integer.parseInt(s); s = inFile.getName().substring(3, 5); c2 = Integer.parseInt(s); BufferedImage image = null; image = ImageIO.read(inFile); images[c1 * cols + c2] = image; } } catch (IOException e) { System.err.println(e); System.exit(1); } // Our map tiles are square, with dimensions of 256 by 256 pixels. With 4 rows and //4 // columns, we create a 1024 by 1024 image. BufferedImage outputImage = new BufferedImage(256 * cols, 256 * rows, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = outputImage.createGraphics(); // Loop through the rows and columns for (i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { g.drawImage(images[i * cols + j], j * 256, i * 256, 256, 256, null); } } try { ImageIO.write(outputImage, "png", outFile); } catch (IOException e) { System.err.println(e); System.exit(1); } }
public static void main(String[] args) throws IOException { if (args.length != 2) { System.out.println( "Usage: java lia.tools.SpellCheckerTest SpellCheckerIndexDir wordToRespell"); System.exit(1); } String spellCheckDir = args[0]; String wordToRespell = args[1]; Directory dir = FSDirectory.open(new File(spellCheckDir)); if (!IndexReader.indexExists(dir)) { System.out.println( "\nERROR: No spellchecker index at path \"" + spellCheckDir + "\"; please run CreateSpellCheckerIndex first\n"); System.exit(1); } SpellChecker spell = new SpellChecker(dir); // #A spell.setStringDistance(new LevensteinDistance()); // #B // spell.setStringDistance(new JaroWinklerDistance()); String[] suggestions = spell.suggestSimilar(wordToRespell, 5); // #C System.out.println(suggestions.length + " suggestions for '" + wordToRespell + "':"); for (String suggestion : suggestions) System.out.println(" " + suggestion); }
private Core() { boolean f = false; try { for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { NetworkInterface intf = (NetworkInterface) en.nextElement(); for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { InetAddress inetAddress = (InetAddress) enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { String ipAddress = inetAddress.getHostAddress().toString(); this.ip = inetAddress; f = true; break; } } if (f) break; } } catch (SocketException ex) { ex.printStackTrace(); System.exit(1); } this.teams = new HashMap<String, Team>(); this.judges = new HashMap<String, Judge>(); this.problems = new HashMap<String, ProblemInfo>(); this.scheduler = new Scheduler(); this.timer = new ContestTimer(300 * 60); try { readConfigure(); } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(1); } this.scoreBoardHttpServer = new ScoreBoardHttpServer(this.scoreBoardPort); }
public ExampleDownloadFiles(String[] args) { try { TorrentProcessor tp = new TorrentProcessor(); if (args.length < 1) { System.err.println( "Incorrect use, please provide the path of the torrent file...\r\n" + "\r\nCorrect use of ExampleDownloadFiles:\r\n" + "ExampleDownloadFiles torrentPath"); System.exit(1); } TorrentFile t = tp.getTorrentFile(tp.parseTorrent(args[0])); if (args.length > 1) Constants.SAVEPATH = args[1]; if (t != null) { DownloadManager dm = new DownloadManager(t, Utils.generateID()); dm.startListening(6881, 6889); dm.startTrackerUpdate(); dm.blockUntilCompletion(); dm.stopTrackerUpdate(); dm.closeTempFiles(); } else { System.err.println("Provided file is not a valid torrent file"); System.err.flush(); System.exit(1); } } catch (Exception e) { System.out.println("Error while processing torrent file. Please restart the client"); // e.printStackTrace(); System.exit(1); } }
@Override public void run() { BufferedReader br = null; try { br = new BufferedReader(new FileReader(lista)); String linha = null; while (br.ready()) { linha = br.readLine(); if (sha1Password(linha).equalsIgnoreCase(getRecebe())) { System.out.println("Senha é : " + linha); System.exit(0); } } } catch (FileNotFoundException ex) { Logger.getLogger(DicionarioSha1.class.getName()).log(Level.SEVERE, null, ex); System.exit(0); } catch (IOException ex) { Logger.getLogger(DicionarioSha1.class.getName()).log(Level.SEVERE, null, ex); System.exit(0); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(DicionarioSha2.class.getName()).log(Level.SEVERE, null, ex); System.exit(0); } finally { try { br.close(); } catch (IOException ex) { Logger.getLogger(DicionarioSha1.class.getName()).log(Level.SEVERE, null, ex); } } }
public static void main(String[] args) { /* * Initialize the library. It must be done before calling any * method of the library. */ setupLibrary(); /* * Run commit example and process error if any. */ try { commitExample(); } catch (SVNException e) { SVNErrorMessage err = e.getErrorMessage(); /* * Display all tree of error messages. * Utility method SVNErrorMessage.getFullMessage() may be used instead of the loop. */ while (err != null) { System.err.println(err.getErrorCode().getCode() + " : " + err.getMessage()); err = err.getChildErrorMessage(); } System.exit(1); } System.exit(0); }
/** * Creates a new entity enumeration icon chooser. * * @param enumeration the enumeration to display in this combo box */ public EnumerationIconChooser(Class<E> enumeration) { super(); this.enumeration = enumeration; try { this.icons = (ImageIcon[]) enumeration.getMethod("getIcons").invoke(null); for (int i = 0; i < icons.length; i++) { addItem(icons[i]); } } catch (NoSuchMethodException ex) { System.err.println( "The method 'getIcons()' is missing in enumeration " + enumeration.getName()); ex.printStackTrace(); System.exit(1); } catch (IllegalAccessException ex) { System.err.println( "Cannot access method 'getIcons()' in enumeration " + enumeration.getName() + ": ex.getMessage()"); ex.printStackTrace(); System.exit(1); } catch (InvocationTargetException ex) { ex.getCause().printStackTrace(); System.exit(1); } }
public static void main(String[] args) { try { int port = DEFAULT_SERVER_PORT; File systemDir = null; if (args.length > 0) { try { port = Integer.parseInt(args[0]); } catch (NumberFormatException e) { System.err.println("Error parsing port: " + e.getMessage()); System.exit(-1); } systemDir = new File(args[1]); } final Server server = new Server( systemDir, System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null); initLoggers(); server.start(port); System.out.println("Server classpath: " + System.getProperty("java.class.path")); System.err.println(SERVER_SUCCESS_START_MESSAGE + port); } catch (Throwable e) { System.err.println(SERVER_ERROR_START_MESSAGE + e.getMessage()); e.printStackTrace(System.err); System.exit(-1); } }
/** * Start the benchmark and go to the chosen one. * * @param args */ public void start(String[] args) throws InterruptedException, Exception { // Process command line parameters if (args.length != 1) { System.out.print(getHelp(args)); System.exit(-1); } ParameterEnum benchmarkEnum = null; try { benchmarkEnum = ParameterEnum.valueOf(args[0].replace("-", "").toUpperCase()); } catch (IllegalArgumentException iae) { System.out.print(getHelp(args)); logger.error("Program called with invalid parameter. Shutting down."); System.exit(-1); } logger.info("Starting up {}.", NeddyBenchmark.class.getSimpleName()); // Registers a shutdown hook to free resources of this class. Runtime.getRuntime() .addShutdownHook(new ShutdownThread(this, "NettyBenchmark Shutdown Thread")); // Gets the proper benchmark class. Benchmark benchmark = BenchmarkFactory.getBenchmark(benchmarkEnum); // Setup the proper event pipeline factory for the benchmark. ChannelPipelineFactory pipelineFactory = benchmark.getPipeline(); getBootstrap().setPipelineFactory(pipelineFactory); // Set some necessary or convenient socket options in the bootstrap. benchmark.configureBootstrap(getBootstrap()); // Execute the requested benchmark. benchmark.execute(); }
public static void main(String[] args) throws XMPPException { // List<String> nodeList; // List<String> subNodeList; XmppManager verbindung = new XmppManager(); if (verbindung.verbinden() == false) { System.out.println("Verbindung konnte nicht hergestellt werden!"); System.exit(1); } if (verbindung.managePubSub() == false) { System.out.println("Pub-Sub Manager konnte nicht erstellt werden"); System.exit(1); } if (verbindung.login("veranstalter", "veranstalter") == false) { System.out.println("Fehler beim Einloggen"); System.exit(1); } // if(verbindung.createLeaf("bla") == false){ // System.out.println("Fehler beim Erstellen eines Leafs."); // } // else{ // System.out.println("Leaf wurde erstellt."); // } }
public static void connectDatabase() { try { Class.forName("com.mysql.jdbc.Driver"); String databaseURL = "jdbc:mysql://76.219.184.137:3306/PVPWorld"; // Statement stmnt; databaseConnection = DriverManager.getConnection(databaseURL, "PVPWorldServer", "WarePhant8"); // stmnt = con.createStatement(); // stmnt.executeUpdate("CREATE TABLE myTable(test_id int,test_val char(15) not null)"); // stmnt.executeUpdate("INSERT INTO myTable(test_id, test_val) VALUES(1,'One')"); // stmnt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); // ResultSet rs = stmnt.executeQuery("SELECT * from myTable ORDER BY test_id"); // System.out.println("Display all results:"); // while(rs.next()){ // int theInt= rs.getInt("test_id"); // String str = rs.getString("test_val"); // System.out.println("\ttest_id= " + theInt // + "\tstr = " + str); // }//end while loop } catch (ClassNotFoundException e1) { e1.printStackTrace(); System.exit(1); } catch (SQLException e) { e.printStackTrace(); System.exit(1); } }
private static void checkFileForCompileError(File file) { boolean isClass = file.getName().endsWith(".class"); if ("|CheckInputOutput|AutomaticGrader|TextIO|" .contains("|" + file.getName().replace(".java", "").replace(".class", "") + "|")) return; try { byte[] buffer = new byte[(int) file.length()]; BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); bis.read(buffer); String sourceCode; if (isClass) sourceCode = new String(buffer); else sourceCode = new String(buffer, "UTF8"); // TextIO.putln(sourceCode); if (sourceCode.contains("Unresolved compilation problem")) { System.out.println( "Fix Compilation Errors in " + file.getName() + " - see the Package explorer or Problems view for details."); System.exit(1); } if (sourceCode.contains("System.exit")) { System.out.println( "Don't use System.exit (file: " + file.getName() + ")- see README instructions"); System.exit(1); } if (file.getName().endsWith("Test.java")) checkTestUnmodified(file, sourceCode); bis.close(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
public void runReporteVentasPorAnualContado(String fecha) { try { String master = System.getProperty("user.dir") + "/src/ComponenteReportes/ReporteVentasPorAnualContado.jasper"; // System.out.println("master" + master); if (master == null) { System.out.println("no encuentro el archivo de reporte maestro"); System.exit(2); } JasperReport masterReport = null; try { masterReport = (JasperReport) JRLoader.loadObject(master); } catch (JRException e) { System.out.println("error cargando el reporte maestro:" + e.getMessage()); System.exit(3); } Map parametro = new HashMap(); parametro.put("fecha", fecha); JasperPrint jasperPrint = JasperFillManager.fillReport(masterReport, parametro, cnn); JasperViewer jviewer = new JasperViewer(jasperPrint, false); jviewer.setTitle("REPORTE VENTAS A CONTADO ANUAL"); jviewer.setVisible(true); cnn.close(); } catch (Exception j) { System.out.println("mensaje de error:" + j.getMessage()); } }
/** * invoke as: <CODE> * java -cp <classpath> parallel.distributed.PDBTExecSingleCltWrkInitSrv [workers_port(7890)] [client_port(7891)] * </CODE> * * @param args String[] */ public static void main(String[] args) { int wport = 7890; // default port int cport = 7891; if (args.length > 0) { try { wport = Integer.parseInt(args[0]); } catch (Exception e) { e.printStackTrace(); usage(); System.exit(-1); } if (args.length > 1) { try { cport = Integer.parseInt(args[1]); } catch (Exception e) { e.printStackTrace(); usage(); System.exit(-1); } } } PDBTExecSingleCltWrkInitSrv server = new PDBTExecSingleCltWrkInitSrv(wport, cport); try { server.run(); } catch (Exception e) { e.printStackTrace(); System.err.println("Server exits due to exception."); } }
/** * 验证项目是否ok * * @param contextPath 项目路径 */ public static boolean isdomainok(String contextPath, String securityKey, String domiankey) { try { if (contextPath.indexOf("127.0.") > -1 || contextPath.indexOf("192.168.") > -1) { return true; } String dedomaininfo = PurseSecurityUtils.decryption(domiankey, securityKey); Gson gson = new Gson(); JsonParser jsonParser = new JsonParser(); JsonObject jsonObject = jsonParser.parse(dedomaininfo).getAsJsonObject(); Map<String, String> map = gson.fromJson(jsonObject, new TypeToken<Map<String, String>>() {}.getType()); String domain = map.get("domain"); if (contextPath.indexOf(domain) < 0) { System.exit(2); return false; } String dt = map.get("dt"); if (com.yizhilu.os.core.util.StringUtils.isNotEmpty(dt)) { Date t = DateUtils.toDate(dt, "yyyy-MM-dd"); if (t.compareTo(new Date()) < 0) { System.exit(3); return false; } } return true; } catch (Exception e) { return false; } }
/* input defaults to reading the Fakefile, cwd to "." */ public void make(InputStream input, File cwd, String[] args) { try { Parser parser = parse(input, cwd); // filter out variable definitions int firstArg = 0; while (firstArg < args.length && args[firstArg].indexOf('=') >= 0) firstArg++; List<String> list = null; if (args.length > firstArg) { list = new ArrayList<String>(); for (int i = firstArg; i < args.length; i++) list.add(args[i]); } Rule all = parser.parseRules(list); for (int i = 0; i < firstArg; i++) { int equal = args[i].indexOf('='); parser.setVariable(args[i].substring(0, equal), args[i].substring(equal + 1)); } for (Rule rule : all.getDependenciesRecursively()) if (rule.getVarBool("rebuild")) rule.clean(false); String parallel = all.getVar("parallel"); if (parallel != null) all.makeParallel(Integer.parseInt(parallel)); else all.make(); } catch (FakeException e) { System.err.println(e); System.exit(1); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
/** Perform an unified diff between to directory. Only Java file are compared */ public static void main(String[] args) throws Exception { if (args.length != 2) { usageAndExit(); } File dir1 = new File(args[0]); File dir2 = new File(args[1]); if (!directoryExist(dir1) || !directoryExist(dir2)) { System.exit(1); } List<File> files = exploreDirectory(dir1); boolean diffFound = false; for (File file : files) { String file2 = file.toString().replaceFirst(dir1.toString(), dir2.toString()); if (!new File(file2).exists()) { System.err.println(file2 + " does not exist in " + dir2); diffFound = true; continue; } if (DiffPrint.printUnifiedDiff(file.toString(), file2)) { diffFound = true; } } if (diffFound) { System.exit(1); } }