java - getRuntime with pipe? -


i want execute following command in java program. execute first part. part after | not executed

process process = runtime.getruntime().exec(" adb devices | tail -n +2 | cut -sf 1");          process.waitfor(); 

you need run in shell. try this:

process process = runtime.getruntime().exec(new string[] {         "/bin/sh",         "-c",         "adb devices | tail -n +2 | cut -sf 1" }); process.waitfor(); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -