如何在Java中添加UTF-8 BOM?
2022-09-01 13:29:52
我有一个Java存储过程,它使用对象从表中提取记录并创建CS Vfile。Resultset
BLOB retBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
retBLOB.open(BLOB.MODE_READWRITE);
OutputStream bOut = retBLOB.setBinaryStream(0L);
ZipOutputStream zipOut = new ZipOutputStream(bOut);
PrintStream out = new PrintStream(zipOut,false,"UTF-8");
out.write('\ufeff');
out.flush();
zipOut.putNextEntry(new ZipEntry("filename.csv"));
while (rs.next()){
out.print("\"" + rs.getString(i) + "\"");
out.print(",");
}
out.flush();
zipOut.closeEntry();
zipOut.close();
retBLOB.close();
return retBLOB;
但生成的 CSV 文件未显示正确的德语字符。Oracle 数据库的值也为 UTF8。NLS_CHARACTERSET
请建议。