List of usage examples for java.io File getAbsolutePath
public String getAbsolutePath()
From source file:jk.kamoru.test.IMAPMail.java
public static void main(String[] args) { /* if (args.length < 3) {//from www . j av a2 s . c o m System.err.println( "Usage: IMAPMail <imap server hostname> <username> <password> [TLS]"); System.exit(1); } */ String server = "imap.handysoft.co.kr"; String username = "namjk24@handysoft.co.kr"; String password = "22222"; String proto = (args.length > 3) ? args[3] : null; IMAPClient imap; if (proto != null) { System.out.println("Using secure protocol: " + proto); imap = new IMAPSClient(proto, true); // implicit // enable the next line to only check if the server certificate has expired (does not check chain): // ((IMAPSClient) imap).setTrustManager(TrustManagerUtils.getValidateServerCertificateTrustManager()); // OR enable the next line if the server uses a self-signed certificate (no checks) // ((IMAPSClient) imap).setTrustManager(TrustManagerUtils.getAcceptAllTrustManager()); } else { imap = new IMAPClient(); } System.out.println("Connecting to server " + server + " on " + imap.getDefaultPort()); // We want to timeout if a response takes longer than 60 seconds imap.setDefaultTimeout(60000); File imap_log_file = new File("IMAMP-UNSEEN"); try { System.out.println(imap_log_file.getAbsolutePath()); PrintStream ps = new PrintStream(imap_log_file); // suppress login details imap.addProtocolCommandListener(new PrintCommandListener(ps, true)); } catch (FileNotFoundException e1) { imap.addProtocolCommandListener(new PrintCommandListener(System.out, true)); } try { imap.connect(server); } catch (IOException e) { throw new RuntimeException("Could not connect to server.", e); } try { if (!imap.login(username, password)) { System.err.println("Could not login to server. Check password."); imap.disconnect(); System.exit(3); } imap.setSoTimeout(6000); // imap.capability(); // imap.select("inbox"); // imap.examine("inbox"); imap.status("inbox", new String[] { "UNSEEN" }); // imap.logout(); imap.disconnect(); List<String> imap_log = FileUtils.readLines(imap_log_file); for (int i = 0; i < imap_log.size(); i++) { System.out.println(i + ":" + imap_log.get(i)); } String unseenText = imap_log.get(4); unseenText = unseenText.substring(unseenText.indexOf('(') + 1, unseenText.indexOf(')')); int unseenCount = Integer.parseInt(unseenText.split(" ")[1]); System.out.println(unseenCount); //imap_log.indexOf("UNSEEN ") } catch (IOException e) { System.out.println(imap.getReplyString()); e.printStackTrace(); System.exit(10); return; } }
From source file:com.codename1.tools.javadoc.sourceembed.javadocsourceembed.Main.java
public static void main(String[] args) throws Exception { // this accepts two arguments source directory and destination directory where the modfied files will // be written File sourceDir = new File(args[0]); File destDir = new File(args[1]); System.out//w w w. j ava2s. c o m .println("JavaDoc conversion " + sourceDir.getAbsolutePath() + " to " + destDir.getAbsolutePath()); if (!sourceDir.exists() || !sourceDir.isDirectory()) { System.out.println("Source directory doesn't exist"); System.exit(1); return; } CHARSET = Charset.forName("UTF-8"); directoryWalker(sourceDir, destDir); }
From source file:gda.device.detector.mythen.data.DataLoadAlgorithmExperiment.java
public static void main(String args[]) throws Exception { final File dataFile = TestUtils.getResourceAsFile(DataLoadAlgorithmExperiment.class, TEST_FILE); final String filename = dataFile.getAbsolutePath(); StopWatch sw = new StopWatch(DataLoadAlgorithmExperiment.class.getSimpleName()); Algorithm loadUsingCurrentAlgorithm = new Algorithm("loadUsingCurrentAlgorithm") { @Override// w ww .ja v a 2s . com public void run() throws Exception { MythenDataFileUtils.readMythenProcessedDataFile(filename, false); } }; Algorithm loadByUsingSplit = new Algorithm("loadByUsingSplit") { @Override public void run() throws Exception { MythenDataFileUtils.loadByUsingSplit(filename); } }; Algorithm loadByUsingStreamTokenizer = new Algorithm("loadByUsingStreamTokenizer") { @Override public void run() throws Exception { MythenDataFileUtils.loadByUsingStreamTokenizer(filename, FileType.PROCESSED); } }; Algorithm loadByReadingFileContentAndUsingSplit = new Algorithm("loadByReadingFileContentAndUsingSplit") { @Override public void run() throws Exception { MythenDataFileUtils.loadByReadingFileContentAndUsingSplit(filename); } }; Algorithm loadByReadingFileContentAndUsingStreamTokenizer = new Algorithm( "loadByReadingFileContentAndUsingStreamTokenizer") { @Override public void run() throws Exception { MythenDataFileUtils.loadByReadingFileContentAndUsingStreamTokenizer(filename, FileType.PROCESSED); } }; Algorithm[] algorithms = new Algorithm[] { loadUsingCurrentAlgorithm, loadByUsingSplit, loadByUsingStreamTokenizer, loadByReadingFileContentAndUsingSplit, loadByReadingFileContentAndUsingStreamTokenizer }; for (Algorithm a : algorithms) { System.out.printf("Testing '%s' algorithm...\n", a.name); // warm-up for (int i = 0; i < 1000; i++) { a.run(); } // timing sw.start(a.name); for (int i = 0; i < 1000; i++) { a.run(); } sw.stop(); } // display results System.out.println(sw.prettyPrint()); }
From source file:de.dfki.resc28.ole.bootstrap.App.java
public static void main(String[] args) throws IOException { configure();/*from w w w . j a va 2 s.c om*/ initRepoModel(); File[] files = new File(fPartsDirectory).listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".dat"); } }); if (files == null) { System.err.format("Error: %s is not a directory%n", fPartsDirectory); System.exit(1); } int fileCounter = 0; for (File file : files) { System.out.format("Parsing file: %s [%d/%d]...%n", file.getAbsolutePath(), fileCounter + 1, files.length); parseFile(file); fileCounter++; } fGraphStore.addToNamedGraph(fRepo.getURI(), fRepoModel); System.exit(0); }
From source file:com.acmutv.ontoqa.GrammalexMain.java
/** * The app main method, executed when the program is launched. * @param args The command line arguments. * @throws IllegalAccessException /*from w ww. jav a2s. c o m*/ * @throws InstantiationException */ public static void main(String[] args) throws InstantiationException, IllegalAccessException { //CliService.handleArguments(args); RuntimeManager.registerShutdownHooks(new ShutdownHook()); try { Path path = FileSystems.getDefault().getPath("data/lexicon").toAbsolutePath(); String currentDirectory = path.toString(); final JFileChooser fc = new JFileChooser(currentDirectory); int returnVal = fc.showOpenDialog(null); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); if (returnVal == JFileChooser.OPEN_DIALOG) { File file = fc.getSelectedFile(); System.out.println("File Select: " + file.getName() + "\n\n"); List<LexicalEntry> lEntries = LexiconUsage.getLexicalEntries(file.getAbsolutePath(), "", LexiconFormat.RDFXML); Grammar grammar = SerializeSltag.getAllElementarySltag(lEntries); SerializeSltag.writeGrammarOnFile(grammar, fileJson); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.exit(0); }
From source file:net.itransformers.bgpPeeringMap.BgpPeeringMapFromFile.java
public static void main(String[] args) throws Exception { Map<String, String> params = CmdLineParser.parseCmdLine(args); logger.info("input params" + params.toString()); final String settingsFile = params.get("-s"); if (settingsFile == null) { printUsage("bgpPeeringMap.properties"); return;// ww w . jav a2 s .c o m } Map<String, String> settings = loadProperties(new File(System.getProperty("base.dir"), settingsFile)); logger.info("Settings" + settings.toString()); File outputDir = new File(System.getProperty("base.dir"), settings.get("output.dir")); System.out.println(outputDir.getAbsolutePath()); boolean result = outputDir.mkdir(); // if (!result) { // System.out.println("result:"+result); // System.out.println("Unable to create dir: "+outputDir); // return; // } File graphmlDir = new File(outputDir, settings.get("output.dir.graphml")); result = outputDir.mkdir(); // if (!result) { // System.out.println("Unable to create dir: "+graphmlDir); // return; // } XsltTransformer transformer = new XsltTransformer(); byte[] rawData = readRawDataFile(settings.get("raw-data-file")); logger.info("First-transformation has started with xsltTransformator " + settings.get("xsltFileName1")); ByteArrayOutputStream outputStream1 = new ByteArrayOutputStream(); File xsltFileName1 = new File(System.getProperty("base.dir"), settings.get("xsltFileName1")); ByteArrayInputStream inputStream1 = new ByteArrayInputStream(rawData); // transformer.transformXML(inputStream1, xsltFileName1, outputStream1, settings); logger.info("First transformation finished"); File outputFile1 = new File(graphmlDir, "bgpPeeringMap-intermediate.xml"); FileUtils.writeStringToFile(outputFile1, new String(outputStream1.toByteArray())); logger.info("Second transformation started with xsltTransformator " + settings.get("xsltFileName2")); ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream(); File xsltFileName2 = new File(System.getProperty("base.dir"), settings.get("xsltFileName2")); ByteArrayInputStream inputStream2 = new ByteArrayInputStream(outputStream1.toByteArray()); // transformer.transformXML(inputStream2, xsltFileName2, outputStream2, settings); logger.info("Second transformation finished"); File outputFile = new File(graphmlDir, "bgpPeeringMap.graphml"); File nodesFileListFile = new File(graphmlDir, "nodes-file-list.txt"); FileUtils.writeStringToFile(outputFile, new String(outputStream2.toByteArray())); logger.info("Output Graphml saved in a file in" + graphmlDir); FileUtils.writeStringToFile(nodesFileListFile, "bgpPeeringMap.graphml"); ByteArrayInputStream inputStream3 = new ByteArrayInputStream(outputStream2.toByteArray()); ByteArrayOutputStream outputStream3 = new ByteArrayOutputStream(); File xsltFileName3 = new File(System.getProperty("base.dir"), settings.get("xsltFileName3")); // transformer.transformXML(inputStream3, xsltFileName3, outputStream3); }
From source file:com.linkedin.pinot.perf.BitmapPerformanceBenchmark.java
public static void main(String[] args) throws Exception { File indexDir = new File("/home/kgopalak/pinot_perf/index_dir/scinPricing_OFFLINE"); File[] segmentDirs = indexDir.listFiles(); for (File indexSegmentDir : segmentDirs) { iterationSpeed(indexSegmentDir.getAbsolutePath(), "dimension_geo"); }/* w ww .j ava 2 s .c o m*/ }
From source file:com.makkajai.ObjCToCpp.java
/** * Main Method//w ww .j ava 2 s . c om * * @param args - First argument is the input directory to scan and second is the output directory to write files to. * @throws IOException */ public static void main(String[] args) throws IOException { if (args.length < 2) { System.out.println("Invalid Arguments!"); System.out.println( "Usage: java com.makkajai.ObjCToCpp \"<directory to scan for .h and .m files>\" \"<directory to write .h and .cpp files>\""); return; } String inputDirectory = args[0]; String outputDirectory = args[1]; // String inputDirectory = "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/scenes"; // String outputDirectory = "/Users/administrator/playground/projarea/monster-math-cross-platform/monster-math-2/Classes/Makkajai/scenes"; List<String> exceptFiles = new ArrayList<String>(); if (args.length == 3) { BufferedReader bufferedInputStream = new BufferedReader(new FileReader(args[2])); String exceptFile = null; while ((exceptFile = bufferedInputStream.readLine()) != null) { if (exceptFile.equals("")) continue; exceptFiles.add(exceptFile); } } //Getting all the files from the input directory. final List<File> files = new ArrayList<File>(FileUtils.listFiles(new File(inputDirectory), new RegexFileFilter(FILE_NAME_WITH_H_OR_M), DirectoryFileFilter.DIRECTORY)); // String fileName = //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Utils/MakkajaiEnum" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Utils/MakkajaiUtil" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Home" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Activities/gnumchmenu/PlayStrategy" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Characters/Character" // "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Activities/gnumchmenu/GnumchScene" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/ParentScene" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/BaseSkillView" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/YDLayerBase" // ; //The instance of the translator. ObjCToCppTranslator visitor = new ObjCToCppTranslator(); for (int i = 0; i < files.size();) { File currentFile = files.get(i); String filePathRelativeToInput = currentFile.getAbsolutePath().replace(inputDirectory, ""); Date startTime = new Date(); try { final TranslateFileInput translateFileInput = new TranslateFileInput(inputDirectory, outputDirectory, filePathRelativeToInput, false); if (nextFileIsM(currentFile, files, i)) { try { if (isIgnoredFile(filePathRelativeToInput, exceptFiles)) continue; translateFileInput.dryRun = true; visitor.translateFile(translateFileInput); Date stopTime = new Date(); System.out.println("Dry run File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime, stopTime)); Date startTime1 = new Date(); translateFileInput.filePathRelativeToInput = filePathRelativeToInput.replace(H, M); translateFileInput.dryRun = false; visitor.translateFile(translateFileInput); stopTime = new Date(); System.out.println("Processed File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime1, stopTime)); Date startTime2 = new Date(); translateFileInput.filePathRelativeToInput = filePathRelativeToInput; translateFileInput.dryRun = false; visitor.translateFile(translateFileInput); stopTime = new Date(); System.out.println("Processed File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime2, stopTime)); } catch (Exception e) { e.printStackTrace(); System.out.println("###########################Error Processing: " + filePathRelativeToInput + ", Continuing with next set of tiles"); } finally { i += 2; } continue; } if (!isIgnoredFile(filePathRelativeToInput, exceptFiles)) visitor.translateFile(translateFileInput); i++; } catch (Exception e) { e.printStackTrace(); System.out.println("###########################Error Processing: " + filePathRelativeToInput + ", Continuing with next set of tiles"); } finally { Date stopTime = new Date(); // System.out.println("Processed File(s): " + filePathRelativeToInput.replaceAll(H_OR_M, "") + " Time Taken: " + getDelta(startTime, stopTime)); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getHSQLConnection(); System.out.println("Got Connection."); Statement st = conn.createStatement(); st.executeUpdate("create table survey (id int,name varchar);"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); st.executeUpdate("insert into survey (id,name ) values (2,'anotherValue')"); WebRowSet webRS;/*from w ww . j a va 2s . c om*/ ResultSet rs = null; Statement stmt = null; stmt = conn.createStatement(); webRS = null; String sqlQuery = "SELECT * FROM survey WHERE id='1'"; webRS = new WebRowSetImpl(); webRS.setCommand(sqlQuery); webRS.execute(conn); FileWriter fw = null; File file = new File("1.xml"); fw = new FileWriter(file); System.out.println("Writing db data to file " + file.getAbsolutePath()); webRS.writeXml(fw); // convert xml to a String object StringWriter sw = new StringWriter(); webRS.writeXml(sw); System.out.println("=============="); System.out.println(sw.toString()); System.out.println("=============="); fw.flush(); fw.close(); rs.close(); stmt.close(); conn.close(); }
From source file:com.moss.error_reporting.server.ErrorReportServer.java
public static void main(String[] args) throws Exception { File log4jConfigFile = new File("log4j.xml"); if (log4jConfigFile.exists()) { DOMConfigurator.configureAndWatch(log4jConfigFile.getAbsolutePath(), 1000); System.out.println("Configuring with log file " + log4jConfigFile.getAbsolutePath()); } else {/*from w w w . j a va 2 s . c om*/ BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.INFO); } ServerConfiguration config; JAXBContext context = JAXBContext.newInstance(ServerConfiguration.class); JAXBHelper helper = new JAXBHelper(context); File configFile = new File("error-report-server.xml"); if (!configFile.exists()) configFile = new File(new File(System.getProperty("user.dir")), ".error-report-server.xml"); if (!configFile.exists()) configFile = new File("/etc/error-report-server.xml"); if (!configFile.exists()) { config = new ServerConfiguration(); helper.writeToFile(helper.writeToXmlString(config), configFile); System.out.println("Created default config file at " + configFile.getAbsolutePath()); } else { System.out.println("Reading config file at " + configFile.getAbsolutePath()); config = helper.readFromFile(configFile); } new ErrorReportServer(config); }