こんにちは私はjavaを使用してpostgresqlbyteaからファイルを取得するために以下のコードを使用していますが、ファイル内には314530413142313141のような番号があります
File file = new File("c:/test.doc");
FileOutputStream fos = new FileOutputStream(file);
ResultSet rs = st.executeQuery("SELECT * FROM test_bytea where id=" + 1);
if (rs != null) {
while (rs.next()) {
byte[] fileBytes = new byte[1024];
InputStream is = rs.getBinaryStream("type_file");
while (is.read(fileBytes) > 0) {
fos.write(fileBytes);
}
// use the stream in some way here
}
rs.close();
}
コードのどこが悪いのか教えてください。