Laporan get ip

3

Click here to load reader

Transcript of Laporan get ip

Page 1: Laporan get ip

PRAKTEK PEMROGRAMAN JARINGAN KOMPUTER

PROGRAM MENGAMBIL IP KOMPUTER LOKAL DENGAN

MENGGUNAKAN BAHASA PEMROGRAMAN JAVA

Oleh :

Nama : Tri Lestari

NIM : 061130701310

Kelas : 6 CD

JURUSAN TEKNIK KOMPUTER

POLITEKNIK NEGERI SRIWIJAYA

PALEMBANG

2014

Page 2: Laporan get ip

PROGRAM MENGAMBIL IP KOMPUTER LOKAL DENGAN

MENGGUNAKAN BAHASA PEMROGRAMAN JAVA

Listing Program Mengambil IP Komputer Lokal

Nama Program : getIP.java

import java.net.*;

public class getIP{public static void main(String args[]) throws Exception{InetAddress host = null;host = InetAddress.getLocalHost();byte ip[]=host.getAddress();for (int i=0; i<ip.length;i++){if(i>0){System.out.print(".");}System.out.print(ip[i] & 0Xff);}System.out.println();}}

Page 3: Laporan get ip

Hasil Program :

Program di atas adalah program untuk mengambil ip sebuah komputer lokal. Dari

hasil program yang ditampilkan adalah IP yang didapat : 127.0.0.1.