List of usage examples for java.io FileOutputStream close
public void close() throws IOException
From source file:Main.java
public static void main(String[] args) throws IOException { FileOutputStream fos = new FileOutputStream("C://text.txt"); fos.close(); // try to write into underlying stream fos.write(65);//w w w .j a va 2 s . c o m fos.flush(); fos.close(); }
From source file:List.java
public static void main(String args[]) throws Exception { Properties p = System.getProperties(); p.list(System.out);/*from www . j a va2 s . c om*/ FileOutputStream fos = new FileOutputStream("sys.out"); p.store(fos, null); fos.close(); Map map = new TreeMap(p); System.out.println(map); }
From source file:Test.java
public static void main(String[] args) throws Exception { Lock myLock = new ReentrantLock(); Random random = new Random(); myLock.lock();/*from w w w. j a va2 s .com*/ int number = random.nextInt(5); int result = 100 / number; System.out.println("A result is " + result); FileOutputStream file = new FileOutputStream("file.out"); file.write(result); file.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream("test.txt", true); fos.write("Appended".getBytes()); fos.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { String url = "http://www.java2s.com/style/download.png"; String text = "java2s.com"; byte[] b = mergeImageAndText(url, text, new Point(200, 200)); FileOutputStream fos = new FileOutputStream("new.png"); fos.write(b);//from w w w . j a v a2s. co m fos.close(); }
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);/* w ww .j a v a 2 s. 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[] args) throws Exception { FileOutputStream fos = new FileOutputStream("C:/demo.txt", true); fos.write("Appended".getBytes()); fos.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream("C:/demo.txt"); byte b = 01;//w w w . j av a 2 s . c o m fos.write(b); fos.close(); }
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()); String alias = "myalias"; Certificate cert = keystore.getCertificate(alias); File file = null;/*from w w w . ja va 2 s . com*/ byte[] buf = cert.getEncoded(); FileOutputStream os = new FileOutputStream(file); os.write(buf); os.close(); Writer wr = new OutputStreamWriter(os, Charset.forName("UTF-8")); wr.write(new sun.misc.BASE64Encoder().encode(buf)); wr.flush(); }
From source file:Main.java
public static void main(String args[]) throws Exception { Preferences prefsRoot = Preferences.userRoot(); Preferences myPrefs = prefsRoot.node("PreferenceExample"); myPrefs.put("A", "a"); myPrefs.put("B", "b"); myPrefs.put("C", "c"); FileOutputStream fos = new FileOutputStream("prefs.xml"); myPrefs.exportSubtree(fos);/*ww w .ja v a 2s.c om*/ fos.close(); }