本文整理了Java中marytts.util.io.FileUtils
类的一些代码示例,展示了FileUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils
类的具体详情如下:
包路径:marytts.util.io.FileUtils
类名称:FileUtils
[英]A collection of public static utility methods, doing file operations.
[中]公共静态实用程序方法的集合,用于执行文件操作。
代码示例来源:origin: marytts/marytts
private void initFromStream(InputStream in) throws IOException {
String allText = FileUtils.getStreamAsString(in, "ASCII");
String[] lines = allText.split("\n");
initFromLines(lines, 3);
}
代码示例来源:origin: marytts/marytts
public static void copyFolder(String sourceFolder, String targetFolder, boolean bForceDeleteTarget) throws IOException {
if (exists(sourceFolder)) {
if (exists(targetFolder) && bForceDeleteTarget)
delete(targetFolder);
createDirectory(targetFolder);
if (exists(targetFolder)) {
String[] fileList = FileUtils.getFileList(sourceFolder, "*.*");
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
String targetFile = StringUtils.checkLastSlash(targetFolder)
+ StringUtils.getFileName(fileList[i], false);
copy(fileList[i], targetFile);
}
}
} else
System.out.println("Could not create target folder!");
} else
System.out.println("Source folder does not exist!");
}
代码示例来源:origin: marytts/marytts
/**
* @deprecated use {@link org.apache.commons.io.IOUtils#toString(InputStream, String)} instead
* @param inputStream
* inputStream
* @param encoding
* encoding
* @throws IOException
* IOException
* @return getReaderAsString
*/
@Deprecated
public static String getStreamAsString(InputStream inputStream, String encoding) throws IOException {
return getReaderAsString(new InputStreamReader(inputStream, encoding));
}
代码示例来源:origin: marytts/marytts
public static void delete(String file) {
if (exists(file)) {
delete(file, false);
}
}
代码示例来源:origin: marytts/marytts
public boolean checkParams() {
boolean bContinue = true;
wcParams.trainingBaseFolder = StringUtils.checkLastSlash(wcParams.trainingBaseFolder);
wcParams.sourceTrainingFolder = StringUtils.checkLastSlash(wcParams.sourceTrainingFolder);
wcParams.targetTrainingFolder = StringUtils.checkLastSlash(wcParams.targetTrainingFolder);
FileUtils.createDirectory(wcParams.trainingBaseFolder);
if (!FileUtils.exists(wcParams.trainingBaseFolder) || !FileUtils.isDirectory(wcParams.trainingBaseFolder)) {
System.out.println("Error! Training base folder " + wcParams.trainingBaseFolder + " not found.");
bContinue = false;
}
if (!FileUtils.exists(wcParams.sourceTrainingFolder) || !FileUtils.isDirectory(wcParams.sourceTrainingFolder)) {
System.out.println("Error! Source training folder " + wcParams.sourceTrainingFolder + " not found.");
bContinue = false;
}
if (!FileUtils.exists(wcParams.targetTrainingFolder) || !FileUtils.isDirectory(wcParams.targetTrainingFolder)) {
System.out.println("Error! Target training folder " + wcParams.targetTrainingFolder + " not found.");
bContinue = false;
}
wcParams.temporaryCodebookFile = wcParams.codebookFile + ".temp";
return bContinue;
}
代码示例来源:origin: marytts/marytts
public static void copyFolderRecursive(String sourceFolder, String targetFolder, boolean bForceDeleteTarget)
throws IOException {
String fileSeparator = System.getProperty("file.separator");
if (exists(sourceFolder)) {
if (exists(targetFolder) && bForceDeleteTarget)
delete(targetFolder);
createDirectory(targetFolder);
if (exists(targetFolder)) {
String[] fileList = new File(sourceFolder).list();
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
if (!fileList[i].startsWith(".")) {
String source = StringUtils.checkLastSlash(sourceFolder) + fileList[i];
if (new File(source).isDirectory()) {
String newTargetFolder = StringUtils.checkLastSlash(targetFolder) + fileList[i];
copyFolderRecursive(source, newTargetFolder, bForceDeleteTarget);
} else {
String targetFile = StringUtils.checkLastSlash(targetFolder) + fileList[i];
copy(source, targetFile);
}
}
}
}
} else
System.out.println("Could not create target folder!");
} else
System.out.println("Source folder does not exist!");
}
代码示例来源:origin: marytts/marytts
if (FileUtils.isDirectory(args[0])) // Process folder
if (!FileUtils.exists(args[1]))
FileUtils.createDirectory(args[1]);
String[] fileList = FileUtils.getFileList(args[0], "wav");
String outputFolder = StringUtils.checkLastSlash(args[1]);
if (fileList != null) {
代码示例来源:origin: marytts/marytts
String sourceInputLabDir = sourceInputBaseDir + "lab/";
String targetInputLabDir = targetInputBaseDir + "lab/";
if (!FileUtils.exists(sourceInputWavDir)) {
System.out.println("Error! Folder not found: " + sourceInputWavDir);
return;
if (!FileUtils.exists(targetInputWavDir)) {
System.out.println("Error! Folder not found: " + targetInputWavDir);
return;
if (!FileUtils.exists(sourceInputLabDir)) {
System.out.println("Error! Folder not found: " + sourceInputLabDir);
return;
if (!FileUtils.exists(targetInputLabDir)) {
System.out.println("Error! Folder not found: " + targetInputLabDir);
return;
FileUtils.createDirectory(sourceTrainingBaseDir);
FileUtils.createDirectory(targetTrainingBaseDir);
if (!FileUtils.exists(tmpFileOut)) {
if (FileUtils.exists(tmpFileIn)) {
try {
FileUtils.copy(tmpFileIn, tmpFileOut);
} catch (IOException e) {
if (!FileUtils.exists(tmpFileOut)) {
if (FileUtils.exists(tmpFileIn)) {
代码示例来源:origin: marytts/marytts
} else
FileUtils.copy(firstPassOutputWavFile, outputItem.audioFile);
FileUtils.delete(firstPassOutputWavFile);
代码示例来源:origin: marytts/marytts
public static void rename(String existingFile, String newFilename) {
if (exists(existingFile)) {
File oldFile = new File(existingFile);
oldFile.renameTo(new File(newFilename));
}
}
代码示例来源:origin: marytts/marytts
public void read(String festivalUttFile) {
String allText = null;
try {
allText = FileUtils.getFileAsString(new File(festivalUttFile), "ASCII");
} catch (IOException e) {
代码示例来源:origin: marytts/marytts
public static void writeBinaryFile(short[] x, String filename) throws IOException {
DataOutputStream d = new DataOutputStream(new FileOutputStream(new File(filename)));
d.writeInt(x.length);
writeBinaryFile(x, d);
}
代码示例来源:origin: marytts/marytts
public static void delete(String[] files, boolean bDisplayInfo) {
for (int i = 0; i < files.length; i++) {
delete(files[i], bDisplayInfo);
}
}
代码示例来源:origin: marytts/marytts
FileUtils.delete(tempIn);
FileUtils.rename(tempIn, params.codebookFile);
代码示例来源:origin: marytts/marytts
System.out.println("----------------");
String[] resultFiles = FileUtils.getFileList(folders[i], ".txt");
FileUtils.writeTextFile(subjectDurations, totalDurationsFile);
FileUtils.writeTextFile(allResults, completeResultsFile);
代码示例来源:origin: marytts/marytts
/**
* Sampling Rate Conversion doing with SOX.
*
* @param outpath
* @param targetSamplingRate
* @throws IOException
*/
private void samplingRateConverter(String waveFile, int targetSamplingRate) throws IOException {
Runtime rtime = Runtime.getRuntime();
String soxCommandLine = soxPath + " " + waveFile + " -r " + targetSamplingRate + " tempOut.wav";
Process process = rtime.exec(soxCommandLine);
try {
process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
File outFile = new File("tempOut.wav");
if (!outFile.renameTo(new File(waveFile)))
FileUtils.copy(outFile.getAbsolutePath(), waveFile);
}
代码示例来源:origin: marytts/marytts
public static void changeFileExtensions(String folder, String oldExt, String newExt) {
String[] files = getFileNameList(folder, oldExt);
folder = StringUtils.checkLastSlash(folder);
newExt = StringUtils.checkFirstDot(newExt);
if (files != null) {
for (int i = 0; i < files.length; i++) {
int ind = files[i].lastIndexOf(oldExt);
String newFile = folder + files[i].substring(0, ind) + newExt;
FileUtils.rename(files[i], newFile);
System.out.println("Changed extension " + String.valueOf(i + 1) + " of " + String.valueOf(files.length));
}
}
}
代码示例来源:origin: marytts/marytts
float[] tScalesTimes = { 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.3f };
if (FileUtils.isDirectory(args[0])) // Process folder
String[] fileList = FileUtils.getFileList(args[0], "wav");
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
代码示例来源:origin: marytts/marytts
public static String[] getFileList(String directory, String extension) {
return getFileList(directory, extension, true);
}
代码示例来源:origin: marytts/marytts
public static void copyFolderRecursive(String sourceFolder, String targetFolder, boolean bForceDeleteTarget)
throws IOException {
String fileSeparator = System.getProperty("file.separator");
if (exists(sourceFolder)) {
if (exists(targetFolder) && bForceDeleteTarget)
delete(targetFolder);
createDirectory(targetFolder);
if (exists(targetFolder)) {
String[] fileList = new File(sourceFolder).list();
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
if (!fileList[i].startsWith(".")) {
String source = StringUtils.checkLastSlash(sourceFolder) + fileList[i];
if (new File(source).isDirectory()) {
String newTargetFolder = StringUtils.checkLastSlash(targetFolder) + fileList[i];
copyFolderRecursive(source, newTargetFolder, bForceDeleteTarget);
} else {
String targetFile = StringUtils.checkLastSlash(targetFolder) + fileList[i];
copy(source, targetFile);
}
}
}
}
} else
System.out.println("Could not create target folder!");
} else
System.out.println("Source folder does not exist!");
}
内容来源于网络,如有侵权,请联系作者删除!