List of usage examples for java.io File getName
public String getName()
From source file:de.tudarmstadt.ukp.dkpro.argumentation.sequence.report.ConfusionMatrixTools.java
public static void main(String[] args) throws IOException { String path = args[0];//w ww .ja v a 2s . c om for (File file : FileUtils.listFiles(new File(path), new String[] { "csv" }, true)) { if (file.getName().startsWith("tokenLevelPredictions")) { generateNiceTable(file); } } }
From source file:Main.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser("."); FileFilter filter1 = new ExtensionFileFilter("JPG and JPEG", new String[] { "JPG", "JPEG" }); fileChooser.setFileFilter(filter1);// w w w . j a v a 2s.c o m int status = fileChooser.showOpenDialog(null); if (status == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); System.out.println(selectedFile.getParent()); System.out.println(selectedFile.getName()); } else if (status == JFileChooser.CANCEL_OPTION) { System.out.println(JFileChooser.CANCEL_OPTION); } }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setControlButtonsAreShown(false); frame.add(fileChooser, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource(); String command = actionEvent.getActionCommand(); if (command.equals(JFileChooser.APPROVE_SELECTION)) { File selectedFile = theFileChooser.getSelectedFile(); System.out.println(selectedFile.getParent()); System.out.println(selectedFile.getName()); } else if (command.equals(JFileChooser.CANCEL_SELECTION)) { System.out.println(JFileChooser.CANCEL_SELECTION); }/*from www .j a va2s . c o m*/ } }; fileChooser.addActionListener(actionListener); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setControlButtonsAreShown(false); frame.add(fileChooser, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource(); String command = actionEvent.getActionCommand(); if (command.equals(JFileChooser.APPROVE_SELECTION)) { File selectedFile = theFileChooser.getSelectedFile(); System.out.println(selectedFile.getParent()); System.out.println(selectedFile.getName()); } else if (command.equals(JFileChooser.CANCEL_SELECTION)) { System.out.println(JFileChooser.CANCEL_SELECTION); }/*from ww w.j a v a2s. co m*/ } }; fileChooser.addActionListener(actionListener); fileChooser.removeActionListener(actionListener); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { File absolute = new File("/public/html/javafaq/index.html"); File relative = new File("html/javafaq/index.html"); System.out.println("absolute: "); System.out.println(absolute.getName()); System.out.println(absolute.getPath()); System.out.println("relative: "); System.out.println(relative.getName()); System.out.println(relative.getPath()); }
From source file:com.doculibre.constellio.utils.ConstellioAnnotationUtils.java
public static void main(String[] args) { // Will write the code that needs to be placed in addAnnotatedClasses(AnnotationConfiguration) // method...//from ww w . j a v a 2 s . c om File srcDir = new File(args[0]); String entitiesDirPath = "com.doculibre.constellio.entities".replace(".", File.separator); File entitiesDir = new File(srcDir, entitiesDirPath); List<File> javaFiles = (List<File>) org.apache.commons.io.FileUtils.listFiles(entitiesDir, new String[] { ".java" }, true); for (File javaFile : javaFiles) { System.out.println("config.addAnnotatedClass(" + javaFile.getName().replace("java", ".class") + ");"); } }
From source file:com.taobao.tddl.common.SQLPreParserTest.java
public static void main(String[] args) throws IOException { //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-icsg-db0-db15-group-20100901100337-export.xlsx"; //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-tcsg-instance-group-20100901100641-export.xlsx"; int count = 0; long time = 0; File home = new File(System.getProperty("user.dir") + "/appsqls"); for (File f : home.listFiles()) { if (f.isDirectory() || !f.getName().endsWith(".xlsx")) { continue; }// w w w . j ava 2 s . c om log.info("---------------------- " + f.getAbsolutePath()); faillog.info("---------------------- " + f.getAbsolutePath()); Workbook wb = new XSSFWorkbook(new FileInputStream(f)); Sheet sheet = wb.getSheetAt(0); for (Row row : sheet) { Cell cell = row.getCell(2); if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING) { String sql = cell.getStringCellValue(); long t0 = System.currentTimeMillis(); String tableName = SQLPreParser.findTableName(sql); time += System.currentTimeMillis() - t0; count++; log.info(tableName + " <-- " + sql); if (tableName == null) { sql = sql.trim().toLowerCase(); if (isCRUD(sql)) { System.out.println("failed:" + sql); faillog.error("failed:" + sql); } } } } wb = null; } faillog.fatal("------------------------------- finished --------------------------"); faillog.fatal(count + " sql parsed, total time:" + time + ". average time use per sql:" + (double) time / count + "ms/sql"); }
From source file:edu.umn.msi.tropix.proteomics.tools.DTAToMzXML.java
public static void main(final String[] args) throws Exception { if (args.length < 1) { usage();/*from w w w . j a v a 2 s .c o m*/ System.exit(0); } Collection<File> files = null; if (args[0].equals("-files")) { if (args.length < 2) { out.println("No files specified."); usage(); exit(-1); } else { files = new ArrayList<File>(args.length - 1); for (int i = 1; i < args.length; i++) { files.add(new File(args[i])); } } } else if (args[0].equals("-directory")) { File directory; if (args.length < 2) { directory = new File(System.getProperty("user.dir")); } else { directory = new File(args[2]); } files = FileUtilsFactory.getInstance().listFiles(directory, new String[] { "dta" }, false); } else { usage(); exit(-1); } final InMemoryDTAListImpl dtaList = new InMemoryDTAListImpl(); File firstFile = null; if (files.size() == 0) { out.println("No files found."); exit(-1); } else { firstFile = files.iterator().next(); } for (final File file : files) { dtaList.add(FileUtils.readFileToByteArray(file), file.getName()); } final DTAToMzXMLConverter dtaToMzXMLConverter = new DTAToMzXMLConverterImpl(); final MzXML mzxml = dtaToMzXMLConverter.dtaToMzXML(dtaList, null); final String mzxmlName = firstFile.getName().substring(0, firstFile.getName().indexOf(".")) + ".mzXML"; new MzXMLUtility().serialize(mzxml, mzxmlName); }
From source file:org.camunda.bpm.RestDeployment.java
public static void main(String[] args) throws IOException { if (args.length == 0) { System.err.println("No process files specified"); System.exit(1);//from ww w .j a va2 s . c o m } CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("http://localhost:8080/engine-rest/deployment/create"); StringBody deploymentName = new StringBody("myDeployment", ContentType.TEXT_PLAIN); StringBody enableDuplicateFiltering = new StringBody("true", ContentType.TEXT_PLAIN); StringBody deployChangedOnly = new StringBody("true", ContentType.TEXT_PLAIN); MultipartEntityBuilder builder = MultipartEntityBuilder.create().addPart("deployment-name", deploymentName) .addPart("enable-duplicate-filtering", enableDuplicateFiltering) .addPart("deploy-changed-only", deployChangedOnly); for (String resource : args) { File resourceFile = new File(resource); FileBody fileBody = new FileBody(resourceFile); builder.addPart(resourceFile.getName(), fileBody); } HttpEntity httpEntity = builder.build(); httpPost.setEntity(httpEntity); HttpResponse response = httpClient.execute(httpPost); logResponse(response); }
From source file:it.tidalwave.imageio.example.stats.FocalLengthStats.java
public static void main(final String[] args) { try {//from w w w .j a v a 2 s. c o m final PrintWriter out = new PrintWriter(new File(args[1])); new DirectoryWalker() { @Override protected void handleFile(final File file, final int depth, final Collection results) throws IOException { if (file.getName().toUpperCase().endsWith(".NEF")) { System.out.printf("Processing %s...\n", file.getCanonicalPath()); final ImageReader reader = (ImageReader) ImageIO.getImageReaders(file).next(); reader.setInput(ImageIO.createImageInputStream(file)); final IIOMetadata metadata = reader.getImageMetadata(0); final NEFMetadata nefMetadata = (NEFMetadata) metadata; final IFD exifIFD = nefMetadata.getExifIFD(); final TagRational focalLength = exifIFD.getFocalLength(); out.println(focalLength.doubleValue()); } } public void start() throws IOException { super.walk(new File(args[0]), new ArrayList<Object>()); } }.start(); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } }