Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ProcessBuilder - make call to systeminfo | find xxx

807589Jun 3 2007 — edited Aug 1 2008
Hi,

the question is if I can make processbuilder execute
systeminfo | find "Total Physical Memory" 
instead of parsing the output given from
ProcessBuilder processBuilder = new ProcessBuilder("systeminfo");
The application I am working on is for personal use only so I don't have to think about multi-lingual stuff or so, even if that would be preferable. The plan is just to get it to work, without JNI or bundled platform-specific executables.

- Adam


edit:

I thought this would work but it's not.
		ProcessBuilder processBuilder = new ProcessBuilder("systeminfo | find \"Total Physical Memory:\"");
		
		try {
			Process process = processBuilder.start();
			
			InputStream is = process.getInputStream();
			InputStreamReader isr = new InputStreamReader(is);
			BufferedReader br = new BufferedReader(isr);
			
			String line;
			
			while ((line = br.readLine()) != null) {
				System.out.println(line);
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2008
Added on Jun 3 2007
5 comments
301 views