Hi I am creating a rest api which returns the details of an executable file as response. My requirement is if i send a request to start an executable file,the response should show the details of the executable file that it is started. In my code am giving a path where the details of the executable file are also stored in a .txt file.But if am giving the path of the .txt file in my code to store the details the rest api is not returning any response. If I remove the path of the .txt file the response is given as expected.Any ideas as where am going wrong.below is the code snippet. The code to save the details in a.txt file is
*****d[+] C:\\Debug\\logfile.txt*****
javacode:
public String startServer() throws IOException, InterruptedException{
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\test.exe -d[+] C:\\Debug\\logfile.txt");
BufferedReader input = new BufferedReader(new InputStreamReader
(pr.getInputStream()));
String line=null;
StringBuffer start= new StringBuffer();
while((line=input.readLine()) != null) {
start.append(line + "\n");
System.out.println(line);
}
int exitVal = pr.waitFor();
System.out.println("Exited with error code "+exitVal);
return start.toString();
}
}
Webservice:
@Path("/server")
public class LicenseServer {
@GET
@Path("start")
@Produces({"text/plain","application/xml","application/json"})
//@Consumes({ "application/xml", "application/json", "application/x-www-form-
urlencoded" })
public String getServer() throws IOException, InterruptedException{
StartServer start = new StartServer();
return start.startServer();
}