本文整理了Java中marytts.util.io.FileUtils.close()
方法的一些代码示例,展示了FileUtils.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.close()
方法的具体详情如下:
包路径:marytts.util.io.FileUtils
类名称:FileUtils
方法名:close
[英]Close a PreparedStatement and a series of result sets. Use this in a finally clause. While closing the PreparedStatement supposedly closes it's resultsets, i was told that some buggy implementations don't. Exists because PreparedStatement and ResultŜet are only closeable on jdk 1.7
[中]关闭PreparedStatement和一系列结果集。在finally子句中使用。关闭PreparedStatement可能会关闭它的结果集,但有人告诉我,有些错误的实现并不存在,因为PreparedStatement和ResultŜet只能在jdk 1.7上关闭
代码示例来源:origin: marytts/marytts
public static void writeToTextFile(double[] array, String textFile) {
FileWriter outFile = null;
PrintWriter out = null;
try {
outFile = new FileWriter(textFile);
out = new PrintWriter(outFile);
for (int i = 0; i < array.length; i++) {
out.println(String.valueOf(array[i]));
}
} catch (IOException e) {
System.out.println("Error! Cannot create file: " + textFile);
} finally {
close(outFile, out);
}
}
代码示例来源:origin: marytts/marytts
public static void writeToTextFile(double[] array, String textFile) {
FileWriter outFile = null;
PrintWriter out = null;
try {
outFile = new FileWriter(textFile);
out = new PrintWriter(outFile);
for (int i = 0; i < array.length; i++) {
out.println(String.valueOf(array[i]));
}
} catch (IOException e) {
System.out.println("Error! Cannot create file: " + textFile);
} finally {
close(outFile, out);
}
}
代码示例来源:origin: marytts/marytts
public static int[] readFromBinaryFile(String filename) throws IOException {
DataInputStream d = null;
try {
d = new DataInputStream(new FileInputStream(new File(filename)));
int[] x = null;
int len = d.readInt();
if (len > 0) {
x = new int[len];
for (int i = 0; i < len; i++) {
x[i] = d.readInt();
}
}
return x;
} finally {
close(d);
}
}
代码示例来源:origin: marytts/marytts
public static int[] readFromBinaryFile(String filename) throws IOException {
DataInputStream d = null;
try {
d = new DataInputStream(new FileInputStream(new File(filename)));
int[] x = null;
int len = d.readInt();
if (len > 0) {
x = new int[len];
for (int i = 0; i < len; i++) {
x[i] = d.readInt();
}
}
return x;
} finally {
close(d);
}
}
代码示例来源:origin: marytts/marytts
public static void copy(File source, File dest) throws IOException {
FileChannel in = null, out = null;
try {
System.out.println("copying: " + source + "\n --> " + dest);
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, in.size());
out.write(buf);
} catch (Exception e) {
System.out.println("Error copying file " + source.getAbsolutePath() + " to " + dest.getAbsolutePath() + " : "
+ e.getMessage());
throw new IOException();
} finally {
FileUtils.close(in, out);
}
}
代码示例来源:origin: marytts/marytts
public static byte[] getFileAsBytes(File file) throws IOException {
InputStream is = null;
try {
is = new FileInputStream(file);
long length = file.length();
if (length > Integer.MAX_VALUE) {
return null;
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while ((offset < bytes.length) && ((numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)) {
offset += numRead;
}
if (offset < bytes.length) {
throw new IOException("Could not read file " + file.getName());
}
return bytes;
} finally {
close(is);
}
}
代码示例来源:origin: marytts/marytts
public static void copy(File source, File dest) throws IOException {
FileChannel in = null, out = null;
try {
System.out.println("copying: " + source + "\n --> " + dest);
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, in.size());
out.write(buf);
} catch (Exception e) {
System.out.println("Error copying file " + source.getAbsolutePath() + " to " + dest.getAbsolutePath() + " : "
+ e.getMessage());
throw new IOException();
} finally {
FileUtils.close(in, out);
}
}
代码示例来源:origin: marytts/marytts
public static byte[] getFileAsBytes(File file) throws IOException {
InputStream is = null;
try {
is = new FileInputStream(file);
long length = file.length();
if (length > Integer.MAX_VALUE) {
return null;
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while ((offset < bytes.length) && ((numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)) {
offset += numRead;
}
if (offset < bytes.length) {
throw new IOException("Could not read file " + file.getName());
}
return bytes;
} finally {
close(is);
}
}
代码示例来源:origin: marytts/marytts
close(from, to);
代码示例来源:origin: marytts/marytts
close(from, to);
代码示例来源:origin: de.dfki.mary/marytts-builder
e.printStackTrace();
} finally {
FileUtils.close(psFeaturesSet);
内容来源于网络,如有侵权,请联系作者删除!