List of usage examples for java.io BufferedInputStream BufferedInputStream
public BufferedInputStream(InputStream in)
BufferedInputStream
and saves its argument, the input stream in
, for later use. From source file:Main.java
public static void main(String[] args) { String srcFile = "test.txt"; try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile))) { // Read one byte at a time and display it byte byteData; while ((byteData = (byte) bis.read()) != -1) { System.out.print((char) byteData); }/* w w w . j a va2 s . c o m*/ } catch (Exception e2) { e2.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] buffer = new byte[1024]; BufferedInputStream bufferedInput = new BufferedInputStream(new FileInputStream("filename.txt")); int bytesRead = 0; while ((bytesRead = bufferedInput.read(buffer)) != -1) { String chunk = new String(buffer, 0, bytesRead); System.out.print(chunk);//www.jav a 2s . c om } bufferedInput.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedInputStream is = new BufferedInputStream(new FileInputStream("a.exe")); byte[] bytes = new byte[1024]; int len = 0;// w ww . j ava2s . c o m while ((len = is.read(bytes)) >= 0) { new CRC32().update(bytes, 0, len); } is.close(); System.out.println(Arrays.toString(bytes)); }
From source file:Main.java
public static void main(String[] args) throws Exception { DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("temp.tmp"))); for (int i = 0; i < 10; i++) dis.readInt();/* w ww . j av a2 s . c o m*/ dis.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("temp.tmp"))); for (int i = 0; i < 10; i++) dis.readInt();//from w w w . jav a2 s.co m dis.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { BufferedInputStream fin = new BufferedInputStream(new FileInputStream("in.dat")); BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream("out.dat")); int i;//from w ww . j av a2 s . c o m do { i = fin.read(); if (i != -1) fout.write(i); } while (i != -1); fin.close(); fout.close(); }
From source file:BufferedInputStreamDemo.java
public static void main(String args[]) throws Exception { FileInputStream fis = new FileInputStream(args[0]); BufferedInputStream bis = new BufferedInputStream(fis); int i;/*from w ww . j av a2 s . c o m*/ while ((i = bis.read()) != -1) { System.out.println(i); } fis.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream("infilename.xml"))); MyClass o = (MyClass) decoder.readObject(); decoder.close();/*from w ww . j a va2 s. com*/ int prop = o.getProp(); // 1 int[] props = o.getProps(); // [1, 2, 3] }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create an input stream on a file InputStream is = new BufferedInputStream(new FileInputStream("output.xml")); // Import preference data Preferences.importPreferences(is); }
From source file:Main.java
public static void main(String[] args) throws Exception { InputStream inStream = new FileInputStream("c:/test.txt"); BufferedInputStream bis = new BufferedInputStream(inStream); // read until a single byte is available while (bis.available() > 0) { // read the byte and convert the integer to character char c = (char) bis.read(); System.out.println(c);//w w w. j a v a 2 s . co m } }