List of usage examples for java.io FileInputStream FileInputStream
public FileInputStream(FileDescriptor fdObj)
FileInputStream
by using the file descriptor fdObj
, which represents an existing connection to an actual file in the file system. From source file:Main.java
public static void main(String[] argv) throws Exception { FileInputStream is = new FileInputStream("your.keystore"); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(is, "my-keystore-password".toCharArray()); Enumeration e = keystore.aliases(); for (; e.hasMoreElements();) { String alias = (String) e.nextElement(); java.security.cert.Certificate cert = keystore.getCertificate(alias); if (cert instanceof X509Certificate) { X509Certificate x509cert = (X509Certificate) cert; // Get subject Principal principal = x509cert.getSubjectDN(); String subjectDn = principal.getName(); // Get issuer principal = x509cert.getIssuerDN(); String issuerDn = principal.getName(); }//from ww w . j a v a 2 s. c o m } }
From source file:MainClass.java
public static void main(String[] args) throws IOException { FileInputStream inFile = new FileInputStream(args[0]); FileOutputStream outFile = new FileOutputStream(args[1]); FileChannel inChannel = inFile.getChannel(); FileChannel outChannel = outFile.getChannel(); FileLock outLock = outChannel.lock(); FileLock inLock = inChannel.lock(0, inChannel.size(), true); inChannel.transferTo(0, inChannel.size(), outChannel); outLock.release();//from w w w . j ava 2 s . c o m inLock.release(); inChannel.close(); outChannel.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { boolean bool = false; // create input streams InputStream is = new FileInputStream("C://test.txt"); FilterInputStream fis = new BufferedInputStream(is); // tests if the input stream supports mark() and reset() bool = fis.markSupported();//from w w w . ja v a2 s . co m // prints System.out.print("Supports mark and reset methods: " + bool); }
From source file:Main.java
public static void main(String[] argv) throws Exception { GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream("outfile.gzip")); FileInputStream in = new FileInputStream("infilename"); byte[] buf = new byte[1024]; int len;//from w w w . j av a 2 s .c o m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.finish(); out.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("myimage.gif"); FileInputStream fis = new FileInputStream(file); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//server.local:1521/prod", "scott", "tiger"); conn.setAutoCommit(false);/*w ww . j av a2s . c om*/ PreparedStatement ps = conn.prepareStatement("insert into images values (?,?)"); ps.setString(1, file.getName()); ps.setBinaryStream(2, fis, (int) file.length()); ps.executeUpdate(); ps.close(); fis.close(); }
From source file:Main.java
public static void main(String args[]) { ProgressMonitorInputStream monitor; try {//from w w w .j av a 2 s . co m monitor = new ProgressMonitorInputStream(null, "Loading ", new FileInputStream("yourFile.dat")); while (monitor.available() > 0) { byte[] data = new byte[38]; monitor.read(data); System.out.write(data); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Unable to find file: yourFile.dat", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:Main.java
public static void main(String[] args) { for (int i = 0; i < args.length; i++) { try {/*from w w w . ja v a 2 s. c o m*/ FileInputStream fin = new FileInputStream(args[i]); FileOutputStream fout = new FileOutputStream(args[i] + "dfl"); DeflaterOutputStream dos = new DeflaterOutputStream(fout); for (int c = fin.read(); c != -1; c = fin.read()) { dos.write(c); } dos.close(); fin.close(); } catch (IOException ex) { System.err.println(ex); } } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String inFilename = "infile.gzip"; GZIPInputStream in = new GZIPInputStream(new FileInputStream(inFilename)); String outFilename = "outfile"; OutputStream out = new FileOutputStream(outFilename); byte[] buf = new byte[1024]; int len;//w w w .j a v a2s . co m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
From source file:MainClass.java
public static void main(String[] a) { File aFile = new File("charData.txt"); FileInputStream inFile = null; try {/* w w w . j a v a 2s.c o m*/ inFile = new FileInputStream(aFile); } catch (FileNotFoundException e) { e.printStackTrace(System.err); System.exit(1); } FileChannel inChannel = inFile.getChannel(); }
From source file:Main.java
public static void main(final String[] args) throws IOException { File infile = new File("/tmp/utf16.txt"); FileInputStream inputStream = new FileInputStream(infile); Reader in = new InputStreamReader(inputStream, "UTF-16"); int read;/*from ww w . j ava 2 s . com*/ while ((read = in.read()) != -1) { System.out.print(Character.toChars(read)); } in.close(); }