IO流——缓冲流之BufferedInputStream

    xiaoxiao2026-08-20  1

    package com.io.ioDemo; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class BufferedInputStreamDemo { public static void main(String[] args) { BufferedInputStream bis =null; try { bis = new BufferedInputStream(new FileInputStream(new File("c:\\bis.txt"))); byte[] bt = new byte[1024]; int hasread = 0; while((hasread = bis.read(bt))!=-1){ System.out.println(new String(bt,0,hasread)); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { if(bis!=null){ try { bis.close(); } catch (IOException e) { e.printStackTrace(); } } } } }
    转载请注明原文地址: https://ju.6miu.com/read-1311390.html
    最新回复(0)