Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[JAVA] execute command [newbie only]
#2
ane biasa gini om.. cek os dulu.. klo "win" baru di exec.. CMIIW


PHP Code:
public static void main(String[] args) { String os = System.getProperty("os.name").toLowerCase(); if (os.indexOf("win") == 0) { try { Process p = Runtime.getRuntime().exec("cmd /c ipconfig"); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } } }
/***********************/
Don't blame others, let's say.. we solve it together

[Image: thumb.png]
Reply


Messages In This Thread
[JAVA] execute command [newbie only] - by Dika_xb - 05-09-2012, 07:00 AM
RE: [JAVA] execute command [newbie only] - by Neo_HNc - 05-09-2012, 07:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [java] ftp client using apache commons lib Dika_xb 4 112 03-13-2014, 10:30 PM
Last Post: homeless36
  Membangun Aplikasi Calculator Dengan Java Racifa 8 236 10-30-2013, 02:12 AM
Last Post: Bung Ali
Wah-yellow_16 [java]JAVA HOW TO SEND HTTP POST/GET REQUEST Dika_xb 3 76 09-02-2013, 07:57 PM
Last Post: hogyz
  [HELP] JAVA input char keda 9 117 11-10-2011, 12:31 AM
Last Post: keda
  referensi java bahasa indonesia xnagacode 0 64 11-03-2010, 12:00 PM
Last Post: xnagacode
  Sejarah Bahasa Java ffaaddiill 4 78 08-11-2010, 02:55 AM
Last Post: ffaaddiill
  Melacak IP Address dan alamat Host komputer menggunakan Java s3ns3 12 220 08-10-2010, 12:24 AM
Last Post: ffaaddiill
  komander for newbie t1ku5_g0t 2 51 09-24-2009, 12:30 PM
Last Post: t1ku5_g0t

Forum Jump:


Users browsing this thread: 1 Guest(s)