Guest

www.ethemsulan.com

By: a guest on Mar 6th, 2010  |  syntax: Java  |  size: 0.92 KB  |  hits: 462  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. package www.ethemsulan.com;
  2. import java.util.regex.PatternSyntaxException;
  3. import javax.swing.JOptionPane;
  4. public class IpV4Kontrolu {
  5.         public static void main(String[] args) {
  6.                 try {
  7.                         String girilenIp=JOptionPane.showInputDialog("Bir IpV4 adresi girin");
  8.                         if (girilenIp.matches("\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"))  {
  9.                                 JOptionPane.showMessageDialog(null, girilenIp+" dogru IpV4 adresi girildi");
  10.                         } else {
  11.                                 JOptionPane.showMessageDialog(null, girilenIp+" yanlış IpV4 adresi girildi");
  12.                         }
  13.                 } catch (PatternSyntaxException ex) {
  14.                         ex.printStackTrace();
  15. //127.0.0.1 dogru ipv4 localhost adresi
  16. //299.299.299.299 yanlış 255 ten büyük olamaz.değerler her bir aralık
  17. //255.255.255.256 yanlış max 255 olur.
  18. //0:0:0:0:0:0:0:1 ipv6
  19. //92.168.1.1 doğr ipv4 adresi
  20.                 }
  21.         }
  22. }