marytts.util.io.FileUtils.getStreamAsString()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中marytts.util.io.FileUtils.getStreamAsString()方法的一些代码示例,展示了FileUtils.getStreamAsString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getStreamAsString()方法的具体详情如下:
包路径:marytts.util.io.FileUtils
类名称:FileUtils
方法名:getStreamAsString

FileUtils.getStreamAsString介绍

暂无

代码示例

代码示例来源:origin: marytts/marytts

  1. private void initFromStream(InputStream in) throws IOException {
  2. String allText = FileUtils.getStreamAsString(in, "ASCII");
  3. String[] lines = allText.split("\n");
  4. initFromLines(lines, 3);
  5. }

代码示例来源:origin: marytts/marytts

  1. private void initFromStream(InputStream in) throws IOException {
  2. String allText = FileUtils.getStreamAsString(in, "ASCII");
  3. String[] lines = allText.split("\n");
  4. initFromLines(lines, 3);
  5. }

代码示例来源:origin: marytts/marytts

  1. /**
  2. * Read a file into a string, using the given encoding, and return that string.
  3. *
  4. * @param file
  5. * file
  6. * @param encoding
  7. * encoding
  8. * @throws IOException
  9. * IOException
  10. * @return stream as string(fis, encoding)
  11. * @deprecated use {@link org.apache.commons.io.FileUtils#readFileToString(File, String)} instead
  12. */
  13. @Deprecated
  14. public static String getFileAsString(File file, String encoding) throws IOException {
  15. FileInputStream fis = new FileInputStream(file);
  16. try {
  17. return getStreamAsString(fis, encoding);
  18. } finally {
  19. fis.close();
  20. }
  21. }

代码示例来源:origin: marytts/marytts

  1. /**
  2. * Read a file into a string, using the given encoding, and return that string.
  3. *
  4. * @param file
  5. * file
  6. * @param encoding
  7. * encoding
  8. * @throws IOException
  9. * IOException
  10. * @return stream as string(fis, encoding)
  11. * @deprecated use {@link org.apache.commons.io.FileUtils#readFileToString(File, String)} instead
  12. */
  13. @Deprecated
  14. public static String getFileAsString(File file, String encoding) throws IOException {
  15. FileInputStream fis = new FileInputStream(file);
  16. try {
  17. return getStreamAsString(fis, encoding);
  18. } finally {
  19. fis.close();
  20. }
  21. }

代码示例来源:origin: marytts/marytts

  1. @Before
  2. public void setUp() throws IOException {
  3. targetfeatures = FileUtils.getStreamAsString(FeatureUtilsTest.class.getResourceAsStream("helloworld.targetfeatures"),
  4. "UTF-8");
  5. }

代码示例来源:origin: marytts/marytts

  1. @Test
  2. public void validatingParseString() throws Exception {
  3. String docAsString = FileUtils.getStreamAsString(DomUtilsTest.class.getResourceAsStream("sample.maryxml"), "UTF-8");
  4. DomUtils.parseDocument(docAsString, true);
  5. }

代码示例来源:origin: marytts/marytts

  1. @Before
  2. public void setUp() throws IOException {
  3. targetfeatures = FileUtils.getStreamAsString(FeatureUtilsTest.class.getResourceAsStream("helloworld.targetfeatures"),
  4. "UTF-8");
  5. }

代码示例来源:origin: marytts/marytts

  1. @Test
  2. public void lineArrayConstructor() throws Exception {
  3. String[] lines = FileUtils.getStreamAsString(getClass().getResourceAsStream("pop001.lab"), "ASCII").split("\n");
  4. Labels l = new Labels(lines);
  5. assertEquals(10, l.items.length);
  6. }

代码示例来源:origin: marytts/marytts

  1. public void run() {
  2. try {
  3. InputStream inputStream;
  4. if (args.length == 0 || args[0].equals("-"))
  5. inputStream = System.in;
  6. else
  7. inputStream = new FileInputStream(args[0]);
  8. String input = FileUtils.getStreamAsString(inputStream, "UTF-8");
  9. process(input, MaryProperties.getProperty("input.type", "TEXT"),
  10. MaryProperties.getProperty("output.type", "AUDIO"),
  11. MaryProperties.getProperty("locale", "en_US"), MaryProperties.getProperty("audio.type", "WAVE"),
  12. MaryProperties.getProperty("voice", null), MaryProperties.getProperty("style", null),
  13. MaryProperties.getProperty("effect", null),
  14. MaryProperties.getProperty("output.type.params", null), System.out);
  15. } catch (Exception e) {
  16. throw new RuntimeException(e);
  17. }
  18. }
  19. };

代码示例来源:origin: de.dfki.mary/marytts-client

  1. private String serverInfoRequest(URL url) throws IOException {
  2. HttpURLConnection http = (HttpURLConnection) url.openConnection();
  3. http.setRequestMethod("GET");
  4. http.connect();
  5. if (http.getResponseCode() != HttpURLConnection.HTTP_OK) {
  6. String errorData = "";
  7. try {
  8. errorData = FileUtils.getStreamAsString(http.getErrorStream(), "UTF-8");
  9. } catch (Exception e) {
  10. }
  11. throw new IOException(http.getResponseCode() + ":" + http.getResponseMessage() + "\n" + errorData);
  12. }
  13. return FileUtils.getStreamAsString(http.getInputStream(), "UTF-8");
  14. /*
  15. * The following is example code if we were to use HttpClient: HttpClient httpclient = new DefaultHttpClient();
  16. *
  17. * HttpGet httpget = new HttpGet("http://www.google.com/");
  18. *
  19. * System.out.println("executing request " + httpget.getURI());
  20. *
  21. * // Create a response handler ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody
  22. * = httpclient.execute(httpget, responseHandler); System.out.println(responseBody);
  23. */
  24. }

代码示例来源:origin: de.dfki.mary/marytts-builder

  1. private void copyWithVarSubstitution(String resourceName, File destination, StrSubstitutor... moreSubstitutors)
  2. throws IOException {
  3. String resource = marytts.util.io.FileUtils.getStreamAsString(
  4. getClass().getResourceAsStream("templates/" + resourceName), "UTF-8");
  5. String resourceWithReplacements = substitutor.replace(resource);
  6. for (StrSubstitutor more : moreSubstitutors) {
  7. resourceWithReplacements = more.replace(resourceWithReplacements);
  8. }
  9. PrintWriter out = new PrintWriter(destination, "UTF-8");
  10. out.print(resourceWithReplacements);
  11. out.close();
  12. }

代码示例来源:origin: de.dfki.mary/marytts-client

  1. String error;
  2. try {
  3. error = FileUtils.getStreamAsString(conn.getErrorStream(), "UTF-8");
  4. } catch (IOException errE) {

相关文章