package io;
import java.io.*;
public class IOTest {
    public static void main(String[] args) {
        InputStream in = null;
        OutputStream out = null;
        try {
            in = new BufferedInputStream(new FileInputStream("E:/idea/LOG1b.LOG"));
            out = new BufferedOutputStream(new FileOutputStream("E:/idea/LOG2b.LOG"));
            int len = 0;
            //byte[] byt=new byte[1024];           //1024可变
            long t1 = System.currentTimeMillis();
            /* while ((len = in.read(byt)) != -1) {       //-1表示读到文件末尾返回-1
            out.write(len);
            }*/
            while ((len = in.read()) != -1) {       //-1表示读到文件末尾返回-1
                out.write(len);
            }
            long t2 = System.currentTimeMillis();
            System.out.println(t2 - t1);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {
                e.printStackTrace();              //To change body of catch statement use Options | File Templates.
            }
            try {
                if (out != null)
                    out.close();
            } catch (IOException e) {
                e.printStackTrace();            //To change body of catch statement use Options | File Templates.
            }        }
    }
}

解决方案 »

  1.   

    try {
                oracle.jdbc.OracleDriver drive = new oracle.jdbc.OracleDriver();
                DriverManager.registerDriver(drive);
                Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@liuwei", "scott", "tiger");
                PreparedStatement pstm1 = conn.prepareStatement("insert into wei(id,image) values(?,?)");
                File file1 = new File("d:/idea/111.rar");
                pstm1.setInt(1, 1);
                pstm1.setBinaryStream(2, new FileInputStream(file1), (int) file1.length());
                int ret1 = pstm1.executeUpdate();
                System.out.println(ret1);            PreparedStatement pstm2 = conn.prepareStatement("select image from wei where id = 1");
                ResultSet res2 = pstm2.executeQuery();            res2.next();            InputStream in = res2.getBinaryStream(1);
                FileOutputStream out = new FileOutputStream("d:/idea/222.rar");            int len = 0;
                byte [] buf = new byte[1024];            while ((len = in.read(buf)) != -1) {
                    out.write(buf,0,len);
                }
            } catch (Exception e) {
                e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }
        }
      

  2.   

    抛什么异常你总得说说,
    现在我只能告诉你怎样得到int值:
    int i = Integer.parseInt(b, 2);