【发布时间】:2020-04-14 10:15:14
【问题描述】:
我从 db2 获取 clob 数据并存储在一个列表中,然后写入一个文本文件,但是日语字符没有被编码。
从 db2 获取数据
if (rs != null) {
int slNo = 0;
BufferedReader reader = null;
int counter = 0;
// Read the list of content next
while (rs.next() && !rs.isClosed()) {
// Reserve the first entry in the
// result List for header column
if (counter == 0) {
resultList.add(null);
counter++;
}
reader = new BufferedReader(new InputStreamReader(rs.getAsciiStream(1)));
slNo = rs.getInt(2);
if (slNo == 1) {
resultList.set(0, reader.readLine());
} else {
// result data
resultList.add(reader.readLine());
}}}
写入文件
FileOutputStream outObjectOutputStream = null;
try {
outObjectOutputStream = new FileOutputStream(absoluteFilePath);
for (String line : resultList) {
if (line != null) {
outObjectOutputStream.write(line.getBytes());
outObjectOutputStream.write("\n".getBytes());
}}'
【问题讨论】:
-
我在数据库中有日语字符,当我写入 txt 文件时,它就像 Y'–*^
-
记事本和windows操作系统
-
考虑在 CLOB 列中使用
rs.getClob()而不是rs.getAsciiStream()。 -
让我检查一下
-
它不适合我
标签: java encoding db2 resultset