List of usage examples for java.io File File
public File(URI uri)
From source file:Main.java
public static void main(String[] argv) throws Exception { FileInputStream is = new FileInputStream(new File("your")); CertificateFactory cf = CertificateFactory.getInstance("X.509"); java.security.cert.Certificate cert = cf.generateCertificate(is); }
From source file:MainClass.java
public static void main(String[] a) { File aFile = new File("C:/myFile.text"); FileOutputStream outputFile = null; // Place to store an output stream // reference try {/*w w w . j a v a 2 s. co m*/ // Create the stream opened to write outputFile = new FileOutputStream(aFile); } catch (FileNotFoundException e) { e.printStackTrace(System.err); System.exit(1); } // Get the channel for the file FileChannel outputChannel = outputFile.getChannel(); }
From source file:Main.java
public static void main(String[] args) throws Exception { File root = new File("c:\\"); String[] extensions = { "xml", "java", "dat" }; boolean recursive = true; Collection files = FileUtils.listFiles(root, extensions, recursive); for (Iterator iterator = files.iterator(); iterator.hasNext();) { File file = (File) iterator.next(); System.out.println("File = " + file.getAbsolutePath()); }//from w ww . j a v a 2 s . c om }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipFile zipFile = new ZipFile(new File("testfile.zip"), ZipFile.OPEN_READ, Charset.defaultCharset()); ZipEntry entry = zipFile.getEntry("fileName"); }
From source file:Main.java
License:asdf
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setDialogTitle("asdf"); chooser.showDialog(new JFrame(""), null); File curFile = chooser.getSelectedFile(); }
From source file:Main.java
public static void main(String[] args) { String path = System.getProperty("user.dir", "."); File dir = new File(path); JFileChooser jfc = new JFileChooser(dir); int result = jfc.showOpenDialog(null); switch (result) { case JFileChooser.CANCEL_OPTION: System.out.println("User cancelled OPEN dialog."); break;/*w w w. ja va 2s.c o m*/ case JFileChooser.APPROVE_OPTION: System.out.println("User chose file: " + jfc.getSelectedFile()); break; case JFileChooser.ERROR_OPTION: System.out.println("User encountered an error"); break; default: System.out.println("Confused"); break; } System.exit(0); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.showDialog(new JFrame(""), null); File curFile = chooser.getSelectedFile(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.resetChoosableFileFilters(); chooser.showDialog(new JFrame(""), null); File curFile = chooser.getSelectedFile(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFiles(new File[] { f }); chooser.showDialog(new JFrame(""), null); File curFile = chooser.getSelectedFile(); }
From source file:Main.java
public static void main(String args[]) throws IOException { File file = new File("your file path.jpg"); BufferedImage image = ImageIO.read(file); for (int i = 0; i < image.getHeight(); i++) { for (int j = 0; j < image.getWidth(); j++) { int color = image.getRGB(j, i); // convert the color to a readable format String clr = Integer.toHexString(color).substring(2); System.out.println(clr); }/*from w ww .ja va 2s . c o m*/ } }