Java Path File Write nio writeAudio(String source, String writePath)

Here you can find the source of writeAudio(String source, String writePath)

Description

write Audio

License

Open Source License

Declaration

static Process writeAudio(String source, String writePath) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Paths;

public class Main {
    private static final String WRITER_PATH = Paths
            .get("audio/controller/AudioWriter.exe").toAbsolutePath()
            .toString();

    static Process writeAudio(String source, String writePath) {
        String command = "\"" + WRITER_PATH + "\" \"" + source + "\" "
                + writePath + "";
        Process process = null;//from   w  w  w.  j  ava 2  s  .c o m
        try {
            process = Runtime.getRuntime().exec(command);
            printErrorStream(process);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return process;
    }

    private static void printErrorStream(final Process process) {
        if (process != null) {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try (BufferedReader stdError = new BufferedReader(
                            new InputStreamReader(process.getErrorStream()))) {
                        String error = null;
                        while ((error = stdError.readLine()) != null) {
                            System.err.println(error);
                            Thread.sleep(200);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    }
}

Related

  1. write(List list, String outputPath)
  2. write(Object obj, String filePath)
  3. write(Path p)
  4. write(Path p, String s)
  5. write(Path path, String string)
  6. writeEndStringInFile(Path path, String s)
  7. writeFile(String filePath, String text)
  8. writeFile(String path, String output)
  9. writeFile(String payload, Path balOutPath)