提交 9b21163b authored 作者: Thomas Mueller's avatar Thomas Mueller

Use the file system abstraction whenever possible.

上级 d83e9a32
......@@ -10,7 +10,6 @@ import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -25,7 +24,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import org.h2.constant.SysProperties;
import org.h2.message.Message;
import org.h2.util.FileUtils;
......@@ -221,12 +219,12 @@ public class Csv implements SimpleRowSource {
private void initWrite() throws IOException {
if (output == null) {
try {
OutputStream out = new FileOutputStream(fileName);
OutputStream out = FileUtils.openFileOutputStream(fileName, false);
out = new BufferedOutputStream(out, bufferSize);
output = new BufferedWriter(new OutputStreamWriter(out, streamCharset));
} catch (IOException e) {
} catch (SQLException e) {
close();
throw e;
throw Message.convertToIOException(e);
}
}
}
......
......@@ -10,7 +10,6 @@ import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
......@@ -145,7 +144,7 @@ public class Recover extends Tool implements DataHandler {
* INTERNAL
*/
public static InputStream readBlob(String fileName) throws IOException {
return new BufferedInputStream(new FileInputStream(fileName));
return new BufferedInputStream(FileUtils.openFileInputStream(fileName));
}
private void removePassword(String dir, String db) throws SQLException {
......
......@@ -9,17 +9,21 @@ package org.h2.util;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileWriter;
//import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
import org.h2.message.Message;
import org.h2.message.TraceSystem;
/**
......@@ -105,7 +109,12 @@ public class SortedProperties extends Properties {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
InputStreamReader reader = new InputStreamReader(in, "ISO8859-1");
LineNumberReader r = new LineNumberReader(reader);
FileWriter w = new FileWriter(fileName);
Writer w;
try {
w = new OutputStreamWriter(FileUtils.openFileOutputStream(fileName, false));
} catch (SQLException e) {
throw Message.convertToIOException(e);
}
PrintWriter writer = new PrintWriter(new BufferedWriter(w));
while (true) {
String line = r.readLine();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论