I have some code that does a Runtime exec and parses the results. On linux and Windows7, the code works fine for parsing the system commands, but on Win XP I am getting a blank line (“”) between each line that has content. Any ideas what might be happening here?
Process output = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(output.getInputStream()));
while ((line = br.readLine()) != null)
{
//do stuff
}
There’s a difference between the end of line character(s) for Unix vs Windows:
Unix:
Windows:
This has to be handled by your application.