The Artima Developer Community
Sponsored Link

Java Answers Forum
i'm having an Exception and i don't know why

2 replies on 1 page. Most recent reply: Apr 8, 2002 4:00 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
patrick

Posts: 23
Nickname: patrick
Registered: Mar, 2002

i'm having an Exception and i don't know why Posted: Apr 7, 2002 4:38 AM
Reply to this message Reply
Advertisement
hi,
i'm trying to convert a "192.100.120.1" string into a 64-bit format using Long.parserLong(String)
but i'm having an Exception on execution
please somebody help me to convert this string because i need to compare it to an other Converted String like 193.100.1.2


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: i'm having an Exception and i don't know why Posted: Apr 8, 2002 6:45 AM
Reply to this message Reply
Patrick
For god's haven sake, put the Exception's trace instead of simply urging for help !
:-))
Can't you put a little piece of code giving problem ?
I am to spend 1/2 hour to write a similar piece of code that gives a similar problem ... :-/

Heck then I have better things to do !
(Nothing personnal, it's just that you should provide a little than just a request for help !)

Thomas,
tsmets @ lautre . net

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: i'm having an Exception and i don't know why Posted: Apr 8, 2002 4:00 PM
Reply to this message Reply
Patrick

U kindly sent me directly a mail... signed by root.
I am please to see that you can use a Linux box but I still needed to look for your post to reply to you.
:-/

I believe this is close enough to what you wanna do ?

import java.net.InetAddress;
 
class ConverterLong2long
{
  public static void main(String argv[])
    throws Exception
  { 
    //long p = Long.parseLong("0.0.0.0");
    // long q = Long.parseLong("192.100.1.2");
    // long r = Long.parseLong("2.255.255.255");
    
    // System.out.println("p = " + p );
    // System.out.println("q = " + q);
    // System.out.println("r = " + r);
    InetAddress addr = InetAddress.getByName("altern.org");
    System.out.println ("Name of : " + addr.getHostName()
                        + "\nAddress is : " + showAddress(addr.getAddress() ));       
  }
  
  private static String showAddress (byte[] anAddress)
  {
    StringBuffer buf = new StringBuffer();
    
    for (int i = 0; i<anAddress.length; i++)           
      buf.append((anAddress[i]<0)?256+anAddress[i]:anAddress[i]).append('.');
     
    return buf.toString();  
    
  }
} // Made with Jcreator (www.jcreator.com)


yrs,

thomas,

Flat View: This topic has 2 replies on 1 page
Topic: batch function Previous Topic   Next Topic Topic: Problem with Paging

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use