- /**
- * 通过系统缓冲字节流类提高IO操作效率
- *
- * @param fileFrom
- * @param fileTo
- */
- public static void readWriteBuffer(String fileFrom, String fileTo) {
- InputStream inBuffer = null;
- OutputStream outBuffer = null;
-
- try {
- inBuffer = new BufferedInputStream(new FileInputStream(fileFrom));
- outBuffer = new BufferedOutputStream(new FileOutputStream(fileTo));
-
- int b;
- byte[] buff = new byte[1024];
-
- while ((b = inBuffer.read(buff)) != -1) {
- outBuffer.write(buff);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (inBuffer != null) {
- inBuffer.close();
- inBuffer = null;
- }
- if (outBuffer != null) {
- outBuffer.close();
- outBuffer = null;
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
复制代码 |