List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:com.bluexml.tools.miscellaneous.Translate.java
/** * @param args/*from w w w .j ava2s. co m*/ */ public static void main(String[] args) { System.out.println("Translate.main() 1"); Console console = System.console(); System.out.println("give path to folder that contains properties files"); Scanner scanIn = new Scanner(System.in); try { // TODO Auto-generated method stub String sWhatever; System.out.println("Translate.main() 2"); sWhatever = scanIn.nextLine(); System.out.println("Translate.main() 3"); System.out.println(sWhatever); File inDir = new File(sWhatever); FilenameFilter filter = new FilenameFilter() { public boolean accept(File arg0, String arg1) { return arg1.endsWith("properties"); } }; File[] listFiles = inDir.listFiles(filter); for (File file : listFiles) { prapareFileToTranslate(file, inDir); } System.out.println("please translate text files and press enter"); String readLine = scanIn.nextLine(); System.out.println("Translate.main() 4"); for (File file : listFiles) { File values = new File(file.getParentFile(), file.getName() + ".txt"); writeBackValues(values, file); values.delete(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { scanIn.close(); } }
From source file:examples.MinimizingMakeChangeWithChart.java
/** * Main method. A single command-line argument is expected, which is the * amount of change to create (in other words, 75 would be equal to 75 * cents)./*w ww .j a va 2s .co m*/ * * @param args amount of change in cents to create * @throws Exception * * @author Neil Rotstan * @author Klaus Meffert * @since 1.0 */ public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("Syntax: MinimizingMakeChange <amount> <directory for outputting chart>"); } else { int amount = 0; try { amount = Integer.parseInt(args[0]); } catch (NumberFormatException e) { System.out.println("The <amount> argument must be a valid integer value"); System.exit(1); } if (amount < 1 || amount >= MinimizingMakeChangeFitnessFunction.MAX_BOUND) { System.out.println("The <amount> argument must be between 1 and " + (MinimizingMakeChangeFitnessFunction.MAX_BOUND - 1) + "."); } else { String dir = args[1]; if (!dir.endsWith("\\") && !dir.endsWith("/")) { dir += "\\"; } makeChangeForAmount(amount, dir); } } }
From source file:com.vitco.Main.java
public static void main(String[] args) throws Exception { // display version number on splash screen final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash != null) { Graphics2D g = splash.createGraphics(); if (g != null) { g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); Font font = Font .createFont(Font.TRUETYPE_FONT, new SaveResourceLoader("resource/font/arcade.ttf").asInputStream()) .deriveFont(Font.PLAIN, 42f); g.setFont(font);//from www. jav a 2s . c om //g.setFont(g.getFont().deriveFont(9f)); g.setColor(VitcoSettings.SPLASH_SCREEN_OVERLAY_TEXT_COLOR); int width = g.getFontMetrics().stringWidth(VitcoSettings.VERSION_ID); g.drawString(VitcoSettings.VERSION_ID, 400 - 20 - width, 110); splash.update(); g.dispose(); } } // the JIDE license SaveResourceLoader saveResourceLoader = new SaveResourceLoader("resource/jidelicense.txt"); if (!saveResourceLoader.error) { String[] jidelicense = saveResourceLoader.asLines(); if (jidelicense.length == 3) { com.jidesoft.utils.Lm.verifyLicense(jidelicense[0], jidelicense[1], jidelicense[2]); } } // check if we are in debug mode if ((args.length > 0) && args[0].equals("debug")) { ErrorHandler.setDebugMode(); debug = true; } // build the application final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "com/vitco/glue/config.xml"); // for debugging if (debug) { ((ActionManager) context.getBean("ActionManager")).performValidityCheck(); ((ComplexActionManager) context.getBean("ComplexActionManager")).performValidityCheck(); } // open vsd file when program is started with "open with" MainMenuLogic mainMenuLogic = ((MainMenuLogic) context.getBean("MainMenuLogic")); for (String arg : args) { if (arg.endsWith(".vsd")) { File file = new File(arg); if (file.exists() && !file.isDirectory()) { mainMenuLogic.openFile(file); break; } } } // perform shortcut check ((ShortcutManager) context.getBean("ShortcutManager")).doSanityCheck(debug); // // test console // final Console console = ((Console) context.getBean("Console")); // new Thread() { // public void run() { // while (true) { // console.addLine("text"); // try { // sleep(2000); // } catch (InterruptedException e) { // //e.printStackTrace(); // } // } // } // }.start(); // add a shutdown hook Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { // make reference so Preferences object doesn't get destroyed Preferences pref = ((Preferences) context.getBean("Preferences")); // trigger @PreDestroy context.close(); // store the preferences (this needs to be done here, b/c // some PreDestroys are used to store preferences!) pref.save(); } }); }
From source file:de.fatalix.book.importer.CalibriImporter.java
public static void main(String[] args) throws IOException, URISyntaxException, SolrServerException { Gson gson = new Gson(); CalibriImporterConfiguration config = gson.fromJson(args[0], CalibriImporterConfiguration.class); File importFolder = new File(config.getImportFolder()); if (importFolder.isDirectory()) { File[] zipFiles = importFolder.listFiles(new FilenameFilter() { @Override/* w ww .ja v a2 s. c o m*/ public boolean accept(File dir, String name) { return name.endsWith(".zip"); } }); for (File zipFile : zipFiles) { try { processBooks(zipFile.toPath(), config.getSolrCore(), config.getSolrCore(), config.getBatchSize()); System.out.println("Processed file " + zipFile.getName()); } catch (IOException ex) { ex.printStackTrace(); } } } else { System.out.println("Import folder: " + importFolder.getAbsolutePath() + " cannot be read!"); } }
From source file:com.linkedin.pinot.perf.FilterOperatorBenchmark.java
public static void main(String[] args) throws Exception { String rootDir = args[0];/*from ww w . j a v a2 s. c o m*/ File[] segmentDirs = new File(rootDir).listFiles(); String query = args[1]; AtomicInteger totalDocsMatched = new AtomicInteger(0); Pql2Compiler pql2Compiler = new Pql2Compiler(); BrokerRequest brokerRequest = pql2Compiler.compileToBrokerRequest(query); List<Callable<Void>> segmentProcessors = new ArrayList<>(); long[] timesSpent = new long[segmentDirs.length]; for (int i = 0; i < segmentDirs.length; i++) { File indexSegmentDir = segmentDirs[i]; System.out.println("Loading " + indexSegmentDir.getName()); Configuration tableDataManagerConfig = new PropertiesConfiguration(); List<String> invertedColumns = new ArrayList<>(); FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".bitmap.inv"); } }; String[] indexFiles = indexSegmentDir.list(filter); for (String indexFileName : indexFiles) { invertedColumns.add(indexFileName.replace(".bitmap.inv", "")); } tableDataManagerConfig.setProperty(IndexLoadingConfigMetadata.KEY_OF_LOADING_INVERTED_INDEX, invertedColumns); IndexLoadingConfigMetadata indexLoadingConfigMetadata = new IndexLoadingConfigMetadata( tableDataManagerConfig); IndexSegmentImpl indexSegmentImpl = (IndexSegmentImpl) Loaders.IndexSegment.load(indexSegmentDir, ReadMode.heap, indexLoadingConfigMetadata); segmentProcessors .add(new SegmentProcessor(i, indexSegmentImpl, brokerRequest, totalDocsMatched, timesSpent)); } ExecutorService executorService = Executors.newCachedThreadPool(); for (int run = 0; run < 5; run++) { System.out.println("START RUN:" + run); totalDocsMatched.set(0); long start = System.currentTimeMillis(); List<Future<Void>> futures = executorService.invokeAll(segmentProcessors); for (int i = 0; i < futures.size(); i++) { futures.get(i).get(); } long end = System.currentTimeMillis(); System.out.println("Total docs matched:" + totalDocsMatched + " took:" + (end - start)); System.out.println("Times spent:" + Arrays.toString(timesSpent)); System.out.println("END RUN:" + run); } System.exit(0); }
From source file:kilim.tools.FlowAnalyzer.java
public static void main(String[] args) throws Exception { if (args.length == 0) { log.error("Usage <class name | jar file name> [methodName]"); System.exit(1);/*from ww w.jav a2 s . c o m*/ } String name = args[0]; if (name.endsWith(".jar")) { analyzeJar(name, Detector.DEFAULT); } else { analyzeClass(name, Detector.DEFAULT); } }
From source file:main.ReportGenerator.java
/** * Entry point for the program.//from ww w. j a va2 s. com * Takes the variables as JSON on the standard input. * @param args Arguments from the command line. */ public static void main(String[] args) { CommandLine cmd = createOptions(args); GeneratorError result = GeneratorError.NO_ERROR; try { //Build the output name, by default ./output String directory = cmd.getOptionValue("output", "./"); if (!directory.endsWith(File.separator)) directory += File.separator; String filename = cmd.getOptionValue("name", "output"); String output = directory + filename; //Get the JSON from file if given, or get it from the standard input. String jsonText = null; if (!cmd.hasOption("input")) { // Initializes the input with the standard input jsonText = IOUtils.toString(System.in, "UTF-8"); } else // read the file { FileInputStream inputStream = new FileInputStream(cmd.getOptionValue("input")); try { jsonText = IOUtils.toString(inputStream); } finally { inputStream.close(); } } //Build the report object Report report = new Report(jsonText, cmd.getOptionValue("template"), output); //Generate the document if (cmd.hasOption("all")) { new AllGenerator(report).generate(); } else { if (cmd.hasOption("html")) new HTMLGenerator(report).generate(); if (cmd.hasOption("pdf")) new PDFGenerator(report).generate(); if (cmd.hasOption("doc")) new DocGenerator(report).generate(); } } catch (IOException e) { System.err.println("Error: " + e.getMessage()); System.exit(GeneratorError.IO_ERROR.getCode()); } catch (GeneratorException e) { System.err.println("Error: " + e.getMessage()); System.exit(e.getError().getCode()); } System.exit(result.getCode()); }
From source file:net.itransformers.idiscover.discoverylisteners.XmlTopologyDeviceLogger.java
public static void main(String[] args) throws IOException, JAXBException { String path = "devices_and_models\\lab\\undirected"; File dir = new File(path); String[] files = dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.endsWith(".hml")); }//from w ww . j av a 2 s. c o m }); Map<String, String> params = new HashMap<String, String>(); params.put("path", path); params.put("conf/xslt", "iDiscover\\conf\\xslt\\transformator3.xslt"); XmlTopologyDeviceLogger logger = new XmlTopologyDeviceLogger(params, null, null); for (String fileName : files) { FileInputStream is = new FileInputStream(path + File.separator + fileName); DiscoveredDeviceData discoveredDeviceData; try { discoveredDeviceData = JaxbMarshalar.unmarshal(DiscoveredDeviceData.class, is); } finally { is.close(); } String deviceName = fileName.substring("device-".length(), fileName.length() - ".xml".length()); logger.handleDevice(deviceName, null, discoveredDeviceData, null); } }
From source file:com.example.geomesa.authorizations.GeoServerAuthorizationsTutorial.java
/** * Main entry point. Executes queries against an existing GDELT dataset. * * @param args//from w w w . ja va2 s .c o m * * @throws Exception */ public static void main(String[] args) throws Exception { // read command line options - this contains the path to geoserver and the data store to query CommandLineParser parser = new BasicParser(); Options options = SetupUtil.getWfsOptions(); CommandLine cmd = parser.parse(options, args); String geoserverHost = cmd.getOptionValue(SetupUtil.GEOSERVER_URL); if (!geoserverHost.endsWith("/")) { geoserverHost += "/"; } // create the URL to GeoServer. Note that we need to point to the 'GetCapabilities' request, // and that we are using WFS version 1.0.0 String geoserverUrl = geoserverHost + "wfs?request=GetCapabilities&version=1.0.0"; // create the geotools configuration for a WFS data store Map<String, String> configuration = new HashMap<String, String>(); configuration.put(WFSDataStoreFactory.URL.key, geoserverUrl); configuration.put(WFSDataStoreFactory.WFS_STRATEGY.key, "geoserver"); configuration.put(WFSDataStoreFactory.TIMEOUT.key, cmd.getOptionValue(SetupUtil.TIMEOUT, "99999")); System.out.println("Executing query against '" + geoserverHost + "' with client keystore '" + System.getProperty("javax.net.ssl.keyStore") + "'"); // verify we have gotten the correct datastore WFSDataStore wfsDataStore = (WFSDataStore) DataStoreFinder.getDataStore(configuration); assert wfsDataStore != null; // the geoserver data store to query String geoserverDataStore = cmd.getOptionValue(SetupUtil.FEATURE_STORE); executeQuery(geoserverDataStore, wfsDataStore); }
From source file:UnZip.java
/** * Simple main program, construct an UnZipper, process each .ZIP file from * argv[] through that object./*from www .j av a2 s . com*/ */ public static void main(String[] argv) { UnZip u = new UnZip(); for (int i = 0; i < argv.length; i++) { if ("-x".equals(argv[i])) { u.setMode(EXTRACT); continue; } String candidate = argv[i]; // System.err.println("Trying path " + candidate); if (candidate.endsWith(".zip") || candidate.endsWith(".jar")) u.unZip(candidate); else System.err.println("Not a zip file? " + candidate); } System.err.println("All done!"); }