List of usage examples for java.io OutputStream flush
public void flush() throws IOException
From source file:Main.java
public static void writeShort(OutputStream out, int s) throws IOException { byte[] buffer = new byte[] { (byte) ((s >> 8) & 0xff), (byte) (s & 0xff) }; out.write(buffer);/*from w ww .j a va2 s . c o m*/ out.flush(); buffer = null; }
From source file:MD5.java
public static String getRecoveryMD5() { String MD5string = ""; String recoveryFilename = "/dev/mtd/mtd1"; try {//from w ww . j a v a2s . c o m Process p = Runtime.getRuntime().exec("su"); OutputStream os = p.getOutputStream(); os.write(("md5sum " + recoveryFilename).getBytes()); os.flush(); os.close(); InputStream is = p.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String str = br.readLine(); MD5string = str.split(" ")[0].trim(); is.close(); br.close(); p.destroy(); } catch (Exception e) { System.out.println(e); return null; } System.out.println(MD5string); return MD5string; }
From source file:Main.java
public static boolean bitmap2File(Bitmap bitmap, File imageFile) { OutputStream os; try {/*from www . ja v a2 s . co m*/ os = new FileOutputStream(imageFile); boolean isOK = bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); os.flush(); os.close(); return isOK; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:com.codelanx.playtime.callable.UUIDFetcher.java
private static void writeBody(HttpURLConnection connection, String body) throws Exception { OutputStream stream = connection.getOutputStream(); stream.write(body.getBytes());/*from ww w . j a va 2 s . c o m*/ stream.flush(); stream.close(); }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] b = new byte[IO_BUFFER_SIZE]; int read;/* ww w . ja v a 2 s . c o m*/ while ((read = in.read(b)) != -1) { out.write(b, 0, read); } out.flush(); }
From source file:Main.java
static void copyData(InputStream from, OutputStream to) throws IOException { byte[] buffer = new byte[1024]; int length;/* w ww.ja v a 2 s . c o m*/ while ((length = from.read(buffer)) > 0) { to.write(buffer, 0, length); } to.flush(); to.close(); from.close(); }
From source file:com.intellectualcrafters.plot.uuid.UUIDFetcher.java
private static void writeBody(final HttpURLConnection connection, final String body) throws Exception { final OutputStream stream = connection.getOutputStream(); stream.write(body.getBytes());/*www . j a va 2s .c o m*/ stream.flush(); stream.close(); }
From source file:Main.java
private static void changePk(int pid) { OutputStream out = process.getOutputStream(); String cmd = "chmod 777 proc/" + pid + "/maps \n"; try {/*from w ww.j av a 2 s. com*/ out.write(cmd.getBytes()); out.flush(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
/** * Performs copy of one stream into another. * @param is - input stream/*from w ww . j a v a2 s . co m*/ * @param os - output stream * @throws IOException */ public static void copyStream(InputStream is, OutputStream os) throws IOException { byte[] buffer = new byte[1024]; int count = 0; while ((count = is.read(buffer)) != -1) { os.write(buffer, 0, count); } os.flush(); }
From source file:Main.java
public static String savetoJPEG(byte[] data, int width, int height, String file) { Rect frame = new Rect(0, 0, width, height); YuvImage img = new YuvImage(data, ImageFormat.NV21, width, height, null); OutputStream os = null; File jpgfile = new File(file); try {/*from w ww. java 2 s . co m*/ os = new FileOutputStream(jpgfile); img.compressToJpeg(frame, 100, os); os.flush(); os.close(); } catch (Exception e) { e.printStackTrace(); } return jpgfile.getPath(); }