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);
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);
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 ();
}
}
}
谢谢!可是显示的信息不对,我希望是以文本方式来显示二进制的内容,即还原。
BufferedReader in = new BufferedReader(
new InputStreamReader(
new FileInputStream(file)
)
);用in.readLine()读行吗?