java.sql.Statement stmt = con.createStatement();
ResultSet r = stmt.executeQuery("SELECT x FROM Table2");
// 现在以 4K 块大小获取列 1 结果:
byte buff = new byte[4096];
while (r.next()) {
Java.io.InputStream fin = r.getAsciiStream(1);
for (;;) {
int size = fin.read(buff);
if (size == -1) { // 到达流末尾
break;
}
// 将新填充的缓冲区发送到 ASCII 输出流:
output.write(buff, 0, size);

解决方案 »

  1.   

    import java.io.*;
    public class bin2asc2
    {
        public static void main( String[] args )
        {
            try
            {
                File f = new File("ran.class");
                FileInputStream fis = new FileInputStream(f);
                int i;
                while ((i = fis.read()) != -1 )
                {
                    char c = (char)i;
                    System.out.println(c);
                }
            }
            catch (IOException e)
            {
                e.printStackTrace ();
            }
        }
    }
      

  2.   

    to: xue_sharp
       谢谢!可是显示的信息不对,我希望是以文本方式来显示二进制的内容,即还原。
      

  3.   

    直接用File file = new File("...");
    BufferedReader in = new BufferedReader(
                             new InputStreamReader(
                                 new FileInputStream(file)
                                  )
                               );用in.readLine()读行吗?