• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Redirecting the output

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
i need to know how to get the Mac address of the network card and
the computer IP .

On windows there is the command ipconfig
if i can execute this command using :

Runtime.getRuntime().exec("ipconfig")
can i store the result in a text file ??
and read this text file later .

(
i know that in Unix it is called Redirecting the output
we used to use it like this : "ps -all >> tempFile.txt"
)

i hope that my request is clear
thx in advance
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get all the network interfaces on the machine, via pure Java, using java.net.NetworkInterface.getNetworkInterfaces(). For each of these, you can get a list of java.net.InetAddress, from which you can get an IP address.

Most machines have one adapter with one IP address, but some are more complicated.

I don't think you can get the MAC address with pure Java. What do you want it for?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic