本文整理了Java中marytts.util.io.FileUtils.getStreamAsString()
方法的一些代码示例,展示了FileUtils.getStreamAsString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getStreamAsString()
方法的具体详情如下:
包路径:marytts.util.io.FileUtils
类名称:FileUtils
方法名:getStreamAsString
暂无
代码示例来源: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
private void initFromStream(InputStream in) throws IOException {
String allText = FileUtils.getStreamAsString(in, "ASCII");
String[] lines = allText.split("\n");
initFromLines(lines, 3);
}
代码示例来源:origin: marytts/marytts
/**
* Read a file into a string, using the given encoding, and return that string.
*
* @param file
* file
* @param encoding
* encoding
* @throws IOException
* IOException
* @return stream as string(fis, encoding)
* @deprecated use {@link org.apache.commons.io.FileUtils#readFileToString(File, String)} instead
*/
@Deprecated
public static String getFileAsString(File file, String encoding) throws IOException {
FileInputStream fis = new FileInputStream(file);
try {
return getStreamAsString(fis, encoding);
} finally {
fis.close();
}
}
代码示例来源:origin: marytts/marytts
/**
* Read a file into a string, using the given encoding, and return that string.
*
* @param file
* file
* @param encoding
* encoding
* @throws IOException
* IOException
* @return stream as string(fis, encoding)
* @deprecated use {@link org.apache.commons.io.FileUtils#readFileToString(File, String)} instead
*/
@Deprecated
public static String getFileAsString(File file, String encoding) throws IOException {
FileInputStream fis = new FileInputStream(file);
try {
return getStreamAsString(fis, encoding);
} finally {
fis.close();
}
}
代码示例来源:origin: marytts/marytts
@Before
public void setUp() throws IOException {
targetfeatures = FileUtils.getStreamAsString(FeatureUtilsTest.class.getResourceAsStream("helloworld.targetfeatures"),
"UTF-8");
}
代码示例来源:origin: marytts/marytts
@Test
public void validatingParseString() throws Exception {
String docAsString = FileUtils.getStreamAsString(DomUtilsTest.class.getResourceAsStream("sample.maryxml"), "UTF-8");
DomUtils.parseDocument(docAsString, true);
}
代码示例来源:origin: marytts/marytts
@Before
public void setUp() throws IOException {
targetfeatures = FileUtils.getStreamAsString(FeatureUtilsTest.class.getResourceAsStream("helloworld.targetfeatures"),
"UTF-8");
}
代码示例来源:origin: marytts/marytts
@Test
public void lineArrayConstructor() throws Exception {
String[] lines = FileUtils.getStreamAsString(getClass().getResourceAsStream("pop001.lab"), "ASCII").split("\n");
Labels l = new Labels(lines);
assertEquals(10, l.items.length);
}
代码示例来源:origin: marytts/marytts
public void run() {
try {
InputStream inputStream;
if (args.length == 0 || args[0].equals("-"))
inputStream = System.in;
else
inputStream = new FileInputStream(args[0]);
String input = FileUtils.getStreamAsString(inputStream, "UTF-8");
process(input, MaryProperties.getProperty("input.type", "TEXT"),
MaryProperties.getProperty("output.type", "AUDIO"),
MaryProperties.getProperty("locale", "en_US"), MaryProperties.getProperty("audio.type", "WAVE"),
MaryProperties.getProperty("voice", null), MaryProperties.getProperty("style", null),
MaryProperties.getProperty("effect", null),
MaryProperties.getProperty("output.type.params", null), System.out);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
代码示例来源:origin: de.dfki.mary/marytts-client
private String serverInfoRequest(URL url) throws IOException {
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("GET");
http.connect();
if (http.getResponseCode() != HttpURLConnection.HTTP_OK) {
String errorData = "";
try {
errorData = FileUtils.getStreamAsString(http.getErrorStream(), "UTF-8");
} catch (Exception e) {
}
throw new IOException(http.getResponseCode() + ":" + http.getResponseMessage() + "\n" + errorData);
}
return FileUtils.getStreamAsString(http.getInputStream(), "UTF-8");
/*
* The following is example code if we were to use HttpClient: HttpClient httpclient = new DefaultHttpClient();
*
* HttpGet httpget = new HttpGet("http://www.google.com/");
*
* System.out.println("executing request " + httpget.getURI());
*
* // Create a response handler ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody
* = httpclient.execute(httpget, responseHandler); System.out.println(responseBody);
*/
}
代码示例来源:origin: de.dfki.mary/marytts-builder
private void copyWithVarSubstitution(String resourceName, File destination, StrSubstitutor... moreSubstitutors)
throws IOException {
String resource = marytts.util.io.FileUtils.getStreamAsString(
getClass().getResourceAsStream("templates/" + resourceName), "UTF-8");
String resourceWithReplacements = substitutor.replace(resource);
for (StrSubstitutor more : moreSubstitutors) {
resourceWithReplacements = more.replace(resourceWithReplacements);
}
PrintWriter out = new PrintWriter(destination, "UTF-8");
out.print(resourceWithReplacements);
out.close();
}
代码示例来源:origin: de.dfki.mary/marytts-client
String error;
try {
error = FileUtils.getStreamAsString(conn.getErrorStream(), "UTF-8");
} catch (IOException errE) {
内容来源于网络,如有侵权,请联系作者删除!