List of usage examples for java.io File getName
public String getName()
From source file:com.cyphercove.dayinspace.desktop.AtlasGenerator.java
public static void main(String[] args) throws Exception { //Delete old pack File oldPackFile = new File(TARGET_DIR + "/" + Assets.MAIN_ATLAS + Assets.ATLAS_EXTENSION); if (oldPackFile.exists()) { System.out.println("Deleting old pack file"); oldPackFile.delete();/* ww w. j a v a 2 s .com*/ } //Delete old font files Collection<File> oldFontFiles = FileUtils.listFiles(new File(TARGET_DIR), new RegexFileFilter(".*\\.fnt"), TrueFileFilter.INSTANCE); for (File file : oldFontFiles) { System.out.println("Copying font file: " + file.getName()); FileUtils.deleteQuietly(file); } //Create PNGs for GIF frames GifProcessor gifProcessor = new GifProcessor(0.015f); ArrayList<FileProcessor.Entry> gifFrames = gifProcessor.process(SOURCE_DIR, SOURCE_DIR); //Pack them TexturePacker.Settings settings = new TexturePacker.Settings(); settings.atlasExtension = Assets.ATLAS_EXTENSION; TexturePacker.process(settings, SOURCE_DIR, TARGET_DIR, Assets.MAIN_ATLAS); //Copy over any fonts Collection<File> fontFiles = FileUtils.listFiles(new File(SOURCE_DIR), new RegexFileFilter(".*\\.fnt"), TrueFileFilter.INSTANCE); File destDir = new File(TARGET_DIR); for (File file : fontFiles) { System.out.println("Copying font file: " + file.getName()); FileUtils.copyFileToDirectory(file, destDir); } //Delete the GIF frames that were generated. for (File file : gifProcessor.getGeneratedFiles()) file.delete(); }
From source file:com.manning.blogapps.chapter10.examples.AuthPostJava.java
public static void main(String[] args) throws Exception { if (args.length < 4) { System.out.println("USAGE: authpost <username> <password> <filepath> <url>"); System.exit(-1);//from w w w . j a v a 2 s. c o m } String credentials = args[0] + ":" + args[1]; String filepath = args[2]; URL url = new URL(args[3]); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.setRequestProperty("Authorization", "Basic " + new String(Base64.encodeBase64(credentials.getBytes()))); File upload = new File(filepath); conn.setRequestProperty("name", upload.getName()); String contentType = "application/atom+xml; charset=utf8"; if (filepath.endsWith(".gif")) contentType = "image/gif"; else if (filepath.endsWith(".jpg")) contentType = "image/jpg"; conn.setRequestProperty("Content-type", contentType); BufferedInputStream filein = new BufferedInputStream(new FileInputStream(upload)); BufferedOutputStream out = new BufferedOutputStream(conn.getOutputStream()); byte buffer[] = new byte[8192]; for (int count = 0; count != -1;) { count = filein.read(buffer, 0, 8192); if (count != -1) out.write(buffer, 0, count); } filein.close(); out.close(); String s = null; BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((s = in.readLine()) != null) { System.out.println(s); } }
From source file:com.sonatype.nexus.perftest.PerformanceTestAsserter.java
public static void main(String[] args) throws Exception { final Nexus nexus = new Nexus(); ObjectMapper mapper = new XmlMapper(); mapper.setInjectableValues(new InjectableValues() { @Override//from w w w. j a v a2s . co m public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (Nexus.class.getName().equals(valueId)) { return nexus; } return null; } }); File src = new File(args[0]).getCanonicalFile(); String name = src.getName().substring(0, src.getName().lastIndexOf(".")); Collection<ClientSwarm> swarms = mapper.readValue(src, PerformanceTest.class).getSwarms(); List<Metric> metrics = new ArrayList<>(); for (ClientSwarm swarm : swarms) { metrics.add(swarm.getMetric()); } System.out.println("Test " + name + " metrics:" + metrics); assertTest(name, metrics); System.out.println("Exit"); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { File file = new File("c:\\java.exe"); long size = file.length(); String display = FileUtils.byteCountToDisplaySize(size); System.out.println("Name = " + file.getName()); System.out.println("size = " + size); System.out.println("Display = " + display); }
From source file:Main.java
public static void main(String[] args) { // Create a file filter to show only a directory or .doc files FileFilter filter = new FileFilter() { @Override// ww w . j a v a 2s.c o m public boolean accept(File f) { if (f.isDirectory()) { return true; } String fileName = f.getName().toLowerCase(); if (fileName.endsWith(".doc")) { return true; } return false; // Reject any other files } @Override public String getDescription() { return "Word Document"; } }; // Set the file filter JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(filter); int returnValue = fileChooser.showDialog(null, "Attach"); if (returnValue == JFileChooser.APPROVE_OPTION) { // Process the file } }
From source file:org.opennms.features.vaadin.pmatrix.manual.CalculationDataUnMarshalToCSVTest.java
public static void main(String[] args) { System.out.println(//from w ww. j a v a 2 s . c o m "" + "***********************\n" + "Pmatrix Data to CSV \n" + "***********************\n"); if (args.length < 1) { System.out .println("This program unmarshalls a Pmatrix data file into csv data written to standard out\n" + " To change default values supply arguments: filename.\n"); } else { String filename = args[0]; File file = new File(filename); archiveFileName = file.getName(); archiveFileDirectoryLocation = ("file:" + file.getParent()); } CalculationDataUnMarshalToCSVTest csvtest = new CalculationDataUnMarshalToCSVTest(); csvtest.testLoadAppContext(); csvtest.testUnMarshalCSVData(); }
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 /* w w w . j a v a 2s . co 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:de.kaixo.mubi.lists.MubiListsScraper.java
public static void main(String ars[]) throws XMLStreamException, FactoryConfigurationError, IOException { for (int page = 1; page <= 10; page++) { System.out.println("Fetching page " + page); URL url = new URL(MUBI_LISTS_BASE_URL + "&page=" + page); List<MubiListRef> lists = MubiListsReader.getInstance().readMubiLists(url); for (MubiListRef list : lists) { System.out.println(" Fetching list " + list.getTitle()); List<MubiFilmRef> filmList = MubiListsReader.getInstance() .readMubiFilmList(new URL(MUBI_BASE_URL + list.getUrl())); list.addFilms(filmList);/*from w ww .j av a2s .c om*/ } File outfile = new File("output", "mubi-lists-page-" + String.format("%04d", page) + ".json"); System.out.println("Writing " + outfile.getName()); mapper.writeValue(outfile, lists); } }
From source file:com.bright.utils.rmDuplicateLines.java
public static void main(String args) { File monfile = new File(args); Set<String> userIdSet = new LinkedHashSet<String>(); if (monfile.isFile() && monfile.getName().endsWith(".txt")) { try {/*from w w w. ja v a 2 s . c om*/ List<String> content = FileUtils.readLines(monfile, Charset.forName("UTF-8")); userIdSet.addAll(content); Iterator<String> itr = userIdSet.iterator(); StringBuffer output = new StringBuffer(); while (itr.hasNext()) { output.append(itr.next() + System.getProperty("line.separator")); } BufferedWriter out = new BufferedWriter(new FileWriter(monfile)); String outText = output.toString(); out.write(outText); out.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:disko.PDFDocument.java
public static void main(String[] args) { File dir = new File("/var/tmp/muriloq/mdc/selected"); File[] pdfFiles = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".pdf"); }/*from w w w . j av a 2 s. co m*/ }); for (File f : pdfFiles) { try { System.out.println(f.getName()); PDFDocument pdf = new PDFDocument(f); pdf.getFullText(); System.out.println(pdf.getFullText()); } catch (Throwable t) { t.printStackTrace(); } } }