List of usage examples for java.io OutputStream write
public void write(byte b[], int off, int len) throws IOException
len
bytes from the specified byte array starting at offset off
to this output stream. From source file:Main.java
public static void copy(String src, String dst) throws IOException { InputStream is = null;/*from w w w . j a v a 2 s . com*/ OutputStream os = null; try { is = new FileInputStream(src); os = new FileOutputStream(dst); byte[] buf = new byte[1024]; for (;;) { int n = is.read(buf); if (n <= 0) break; os.write(buf, 0, n); } os.flush(); } finally { if (is != null) is.close(); if (os != null) os.close(); } }
From source file:Main.java
public static boolean write2SDFromString(String path, String fileName, String input) { boolean flag = true; File file = null;//from w w w. j a va 2s .co m OutputStream output = null; try { file = new File(path + fileName); file.createNewFile(); // creatSDDir(path); //file = creatSDFile(path + fileName); output = new FileOutputStream(file); byte buffer[] = input.getBytes(); output.write(buffer, 0, buffer.length); output.flush(); } catch (Exception e) { return false; } finally { try { output.close(); } catch (Exception e) { return flag; } } return flag; }