List of usage examples for java.io FileInputStream close
public void close() throws IOException
From source file:MainClass.java
public static void main(String[] args) throws IOException { FileInputStream fin = new FileInputStream(args[0]); System.out.println(args[0] + ":\t" + getCRC32(fin)); fin.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); FileInputStream fis = new FileInputStream("a.dat"); Certificate cert = certFactory.generateCertificate(fis); fis.close(); System.out.println(cert);/*w w w . ja v a2s .c o m*/ }
From source file:MainClass.java
public static void main(String args[]) throws Exception { char[] oldpass = args[0].toCharArray(); char[] newpass = args[1].toCharArray(); String name = "mykeystore"; FileInputStream in = new FileInputStream(name); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(in, oldpass);//from w ww.j a v a 2s . c o m in.close(); FileOutputStream output = new FileOutputStream(name); ks.store(output, newpass); output.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { FileInputStream file = null; file = new FileInputStream("main.java"); byte x = (byte) file.read(); System.out.println(x);// ww w . j a v a 2s . c o m file.close(); }
From source file:FISTest.java
public static void main(String[] args) throws Exception { XMLInputFactory factory = XMLInputFactory.newInstance(); FileInputStream fis = new FileInputStream("c.xml"); XMLStreamReader reader = factory.createXMLStreamReader(fis); reader.close();/* ww w . ja v a 2 s .co m*/ fis.close(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); FileInputStream in = new FileInputStream(args[0]); java.security.cert.Certificate c = cf.generateCertificate(in); in.close(); X509Certificate t = (X509Certificate) c; System.out.println(t.getVersion()); System.out.println(t.getSerialNumber().toString(16)); System.out.println(t.getSubjectDN()); System.out.println(t.getIssuerDN()); System.out.println(t.getNotBefore()); System.out.println(t.getNotAfter()); System.out.println(t.getSigAlgName()); byte[] sig = t.getSignature(); System.out.println(new BigInteger(sig).toString(16)); PublicKey pk = t.getPublicKey(); byte[] pkenc = pk.getEncoded(); for (int i = 0; i < pkenc.length; i++) { System.out.print(pkenc[i] + ","); }//from w w w. j a va2s .c o m }
From source file:MainClass.java
public static void main(String args[]) throws Exception { String cacert = "mytest.cer"; String lfcert = "lf_signed.cer"; String lfstore = "lfkeystore"; char[] lfstorepass = "wshr.ut".toCharArray(); char[] lfkeypass = "wshr.ut".toCharArray(); CertificateFactory cf = CertificateFactory.getInstance("X.509"); FileInputStream in1 = new FileInputStream(cacert); java.security.cert.Certificate cac = cf.generateCertificate(in1); in1.close(); FileInputStream in2 = new FileInputStream(lfcert); java.security.cert.Certificate lfc = cf.generateCertificate(in2); in2.close();//from ww w .j av a 2 s . c o m java.security.cert.Certificate[] cchain = { lfc, cac }; FileInputStream in3 = new FileInputStream(lfstore); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(in3, lfstorepass); PrivateKey prk = (PrivateKey) ks.getKey("lf", lfkeypass); ks.setKeyEntry("lf_signed", prk, lfstorepass, cchain); FileOutputStream out4 = new FileOutputStream("lfnewstore"); ks.store(out4, "newpass".toCharArray()); out4.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); Statement st = conn.createStatement(); st.executeUpdate("create table survey (Id int, b CLOB);"); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO survey VALUES(1,?)"); File file = new File("c:/Java_Dev/data.txt"); FileInputStream fis = new FileInputStream(file); pstmt.setAsciiStream(1, fis, (int) file.length()); pstmt.execute();/* w w w . ja va 2 s. com*/ fis.close(); st.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); Statement st = conn.createStatement(); st.executeUpdate("create table survey (Id int, b BLOB);"); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO survey VALUES(1,?)"); File file = new File("blob.txt"); FileInputStream fis = new FileInputStream(file); pstmt.setBinaryStream(1, fis, (int) file.length()); pstmt.execute();/*w w w . ja va 2 s. c o m*/ fis.close(); st.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("C:/String.txt"); StringBuffer strContent = new StringBuffer(); FileInputStream fin = new FileInputStream(file); int ch;//w w w . j ava 2 s . c om while ((ch = fin.read()) != -1) { strContent.append((char) ch); } fin.close(); System.out.println(strContent); }