aspose file tools
The moose likes Java in General and the fly likes Redirecting the output Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Redirecting the output" Watch "Redirecting the output" New topic
Author

Redirecting the output

omar bili
Ranch Hand

Joined: Aug 13, 2004
Posts: 177
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
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Redirecting the output
 
Similar Threads
NIC ADDRESS
getting output from DOS into GUI
How to log java.exe errors in bat file
How to Run DOS Commands( ipconfig /All >> a.txt)
results from a dos command line to a txt file