title: Converting an IP address to binary values (Java)
body: <p>I'm trying to write a program in Java that will take an IP address and convert to binary. </p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class IpConverter{
  
  public static void main (String[]args)
  {
  
      int result;
  
      String data_in;
  
      int data_out;
  
          Scanner scan = new Scanner(System.in);
  
          try
          {
              System.out.print("Enter an IP address: ");
              data_in = scan.next();
  
              data_out = Integer.parseInt(data_in, 10);
              System.out.println (data_in + "is equivalent to" + data_out);
          }
          catch (NumberFormatException nfe){
              System.out.println("Wrong data type!");
  
          }
      }
  }
  </code></pre>