我试图使用PowerShell运行class Server {
AudioInputStream audioInputStream;
static AudioInputStream ais;
static AudioFormat format;
static boolean status = true;
static int port = 50005;
static int sampleRate = 44100;
public static void main(String args[]) throws Exception {
DatagramSocket serverSocket = new DatagramSocket(50005);
byte[] receiveData = new byte[3548];
format = new AudioFormat(sampleRate, 16, 1, true, false);
while (status == true) {
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
ByteArrayInputStream baiss = new ByteArrayInputStream(receivePacket.getData());
ais = new AudioInputStream(baiss, format, receivePacket.getLength());
// A thread solve the problem of chunky audio
new Thread(new Runnable() {
@Override
public void run() {
toSpeaker(receivePacket.getData());
}
}).start();
}
// serverSocket.delete();
}
public static void toSpeaker(byte soundbytes[]) {
try {
DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class, format);
SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLineInfo);
sourceDataLine.open(format);
FloatControl volumeControl = (FloatControl) sourceDataLine.getControl(FloatControl.Type.MASTER_GAIN);
volumeControl.setValue(6.0f);
sourceDataLine.start();
sourceDataLine.open(format);
sourceDataLine.start();
System.out.println("format? :" + sourceDataLine.getFormat());
sourceDataLine.write(soundbytes, 0, soundbytes.length);
System.out.println(soundbytes.toString());
sourceDataLine.drain();
sourceDataLine.close();
} catch (Exception e) {
System.out.println("Not working in speakers...");
e.printStackTrace();
}
}
}
命令。
下面是curl
命令
curl
curl --location --request POST "controller/lttrouter/v1/TestResult/process-data-results/" --form "synthesisreport=@"C:\Users\subu\Desktop\testdemo\SynthesisReport.csv";type=text/csv" --form "createdBy=subu" --form "jiraStoryId=LT1235" --form "jiraTaskId=LT1236" --form "tag=demo-test"
上方的命令提示符处于工作状态。
我尝试了以下PowerShell代码
curl
我遇到错误
curl.exe : curl: (26) Failed to open/read local data from file/application At line:13 char:1 + & $CurlExecutable @CurlArguments + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (curl: (26) Fail...ile/application:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
如果我做错了,请提出建议。
答案 0 :(得分:0)
在这种情况下,请勿使用splatting,只需传递参数列表($
而不是@
),正确添加引号并确保$ path得到扩展:
$curlExecutable = "C:\curl-7.65.1-win64-mingw\bin\curl.exe"
$path = "C:\Users\subu\Desktop\Test\SynthesisReport.csv"
Write-Host "CurlFile" $curlExecutable
$curlArguments = "--location","--request", "POST",
"`"controller/lttrouter/v1/TestResult/process-data-results/`"",
"--form", "`"synthesisreport=@`"$path`";type=text/csv`"",
"--form", "`"createdBy=subu`"",
"--form", "`"jiraStoryId=LT1235`"",
"--form", "`"jiraTaskId=LT1236`"",
"--form", "`"tag=demo-test`""
& $curlExecutable $curlArguments