How compare two URLs for equality if one uses jar protocol?

I'm trying to see if some URLs are referring to the same jar file but some of them come with the prepend/append of "jar:file:/" and "!/" and some are just as "file:/". So when I call "URL.equals(...)", it returns false. How do I properly compare these two?
//Returns false, even though both can be used to find the jar file
new URL( "jar:file:/home/me/tmp.jar!/" ).equals( new URL( "file:/home/me/tmp.jar" ) );

The URL with the leading "jar:" and trailing "!/" is a JAR URL. It's described in the JarURLConnection class API document.
This is one way (there any be a simpler one). You will have to figure out whether you're working with a jar URL or a "regular" URL by parsing the URL to figure out which kind it is. One diffrence is the leading "jar"
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class Xy
    public static void main(String[] args)
        throws MalformedURLException, IOException
        URL fileURL =
            new URL("file:/Program Files/Java/jre6/lib/deploy.jar");
        URL jarURL =
            new URL("jar:file:/Program Files/Java/jre6/lib/deploy.jar!/");
        String fURL = fileURL.toString();
        System.out.println("fileURL: " + fURL);
        String jURL = ((JarURLConnection) jarURL.openConnection()).
            getJarFileURL().toString();
        System.out.println("jarURL: " + jURL);
        if (fURL.equals(jURL))
            System.out.println("They are equivalent");
}

Similar Messages

  • Comparing two ResultSets for equality

    Hello,
    I wish to test if two separate ResultSet objects are identical.
    By identical I mean that two different ResultSet objects are identical if
    they contain the same rows in the same order, and each row contains identical values in the two ResultSets.
    Two possibilities could be that the equals() method returns true or that the hashcode() method also produces the same hash value if the objects are identical as described.
    I haven't been able to find any documentation on this issue.
    Does anyone know if either (or both) of these methods have the contract as described above? If so are they guaranteed?
    I can see several potential problems here. Performance with a large ResultSet, duplicate rows, and the ordering of rows not being guaranteed?
    Thanks in advance.
    Tim

    Two possibilities could be that the equals() method
    returns true or that the hashcode() method also
    produces the same hash value if the objects are
    identical as described.I can tell you without looking anything up that these methods do not do that, as doing that would require them to scan the entire result-set, and JDBC tries to avoid doing useless processing. You are going to have to write this code yourself.

  • How to compare two dates to know which one is greater than oher?

    how to compare two dates to know which one is greater than oher?
    Please search before asking basic questions.
    Edited by: Rob Burbank on Mar 27, 2009 9:26 AM

    Hi,
    If thse to date fields are of same type u can directly compare like this.
    regards,
    Bharat.

  • Two urls for portal

    Hi,
    1.Can anybody tell me how to configure two urls for portal?
    2. How can I configure SSL certificates for both the urls?
    our main aim is to have 2 urls one with Kerberos and one with non kerberos.  want to define two urls for these two and want to install SSL certificates. Please help me.
    Thanks
    karunakar.M

    Hi,
    Blog: Using certificates with the SAP NetWeaver Portal
    SAP Help: http://help.sap.com/saphelp_nw70/helpdata/en/65/6a563cef658a06e10000000a11405a/content.htm
    Microsoft: http://support.microsoft.com/kb/931351
    br,
    Tobias

  • Two URLs for same WS

    Hi everyone! I've created a function and I've published it like web service... Now, i see the WS in SE80 (Service Definition --> WSDL tab) and i get URL and WSDL (by example: http://hostname:8000/sap/bc/srt/wsdl/sdef_ZFUNCTIO_001/wsdl11/ws_policy/document?sap-client=100 ).
    Then, i go to SOAMANAGER, and i get another URL (with a little distinct WSDL: http://hostname:8000/sap/bc/srt/wsdl/bndg_E0DE487057B0E7F1A58C005056900046/wsdl11/allinone/ws_policy/document?sap-client=100 ). If i put these in Explorer, both open correctly...
    Why there're two URLs for same WS? Wich is correct?
    Thanks!!

    Hi,
    say for example
    your one URL is
    x.hostname:portno/irj/1stURL
    and the second URL is
    x.hostname:portno/irj/2ndURL
    and maintain two umLogonPagedefault.jsp with names,
    umLogonPage1stURL.jsp and umLogonPage2ndURL.jsp and do the necessary coding you want inside the JSPs.
    Now, umLogonPage.JSP is the JSP file responsible for determinig your portal URL to open when user wants to enter into portal. So Open that JSP(umLogonPage.JSP) and do like this:::
    <%
    String strReqURL = request.getRequestURL().toString()==null?"" : request.getRequestURL().toString() ;
    %>
    <%
    if ( strReqURL != null && strReqURL.endsWith("/1stURL"))     
    %>
         <%@ include file="umLogonPage1stURL.jsp"%>
    <%
    else if ( strReqURL != null && strReqURL.endsWith("/2nuURL"))
    %>
    <%@ include file="umLogonPage2ndURL.jsp"%>
    <%
    %>
    Regards,
    Srinivas.

  • How do people register for more than one person on a form?

    We had a lot of complaints last year from organizations who sent several employees to our training.  It took a long time for them to process these one at a time.  How do people register for more than one person on a form?

    Hi thearcca,
    This entirely depends on the form you create, you can add multiple choice button and ask for the no. of employees the organization wants to register.
    Also, you can add corresponding text field for the names.
    Thanks,
    Vikrantt Singh

  • How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    If you bought a CC for team, you can log in at http://adobe.com and insert the e-mail that you gave at the moment at the purchase and than you can manage and see you product/plan/team.
    If I was not clear you can use the following link to help you solving your issue:
    Creative Cloud Help | Manage your Creative Cloud for teams membership
    If your not clear about this situation, contact with an agent of Adobe, by chat or phone. Use the following link to see the type of support you have on this matter:
    http://adobe.com/getsupport
    I think this will help you.
    Regards

  • How to create Criterian For more than one table

    Hi,
    I have one problem how to create criteria for more than one table in that using one criteria hot to get the values from database in that more than onetable for getting these values .Please send me the exampke code.
    reagrds,
    raghu

    Hi,
    I don't think its possible to create fieldcatalog for different tables,
    but if you want to do so create a dummy table which has all the fields which you want in fieldcatalog.
    populate the data from different table to that dummy table
    then create fieldcatalog for that table and pass it in the function module...
    Regards,
    Siddarth

  • How to handle bdc for more than one transaction?

    how to handle bdc for more than one transaction?

    Hi srk,
    I am providing you with some references below. Hope this prove to be helpful to you.
    Method 1:
    Use one BDC_OPEN_GROUP
    Multiple BDC_INSERT 
    One BDC_CLOSE_GROUP.
    Call function BDC_OPENGROUP.
    Build BDC data and call lBDC_INSERT for transaction 1
    Build BDC data and call lBDC_INSERT for transaction 2
    Build BDC data and call lBDC_INSERT for transaction 3
    paas the tcodes to bdc_insert.
    call function BDC_CLOSE_GROUP.
    Also check this out:
    Here we need to record 2 transactions (shdb).
    Once completion of the recording. Populate the data into input internal table .
    Loop the internal table and process the 2 transactions
    like
    1. BDC_OPEN_GROUP
    2. LOOP AT ITAB
    a. Populate first transaction recording data
    and pass transaction to the BDC_INSERT_GROUP.
    BDC_INSERT_GROUP.
    b. Populate second transaction recording data
    and pass transaction to the BDC_INSERT_GROUP.
    BDC_INSERT_GROUP.
    ENDLOOP.
    3. BDC_CLOSE_GROUP
    the above info can be found at : How to use 2 transactions in BDC?
    Also check this out:
    Suppose u have created recordings for transactions 'MM01' 'XK01' and 'VA01'.
    Then do this:
    bdc_open_group.
    after this we have to fill the bdcdata structure for one transaction.here 'MM01'.
    bdc_insert.
    refresh bdcdata.
    after this we have to fill the bdcdata structure for one transaction.here 'xk01'.
    bdc_insert .
    refresh bdcdata.
    after this we have to fill the bdcdata structure for one transaction.here 'va01'.
    bdc_insert.
    bdc_close_group.
    Hope these are useful to you.
    Please reward if any of the above are useful.
    Regards,
    Kalyan

  • Can I have Photoshop cc on two machines,for solely my own use,with a single subsription?

    My main computer is showing signs of failure,So have bought a new PC .
    Can I have Photoshop cc on two machines,for solely my own use,with a single subsription?

    Yes.
    Creative Cloud Help | Creative Cloud / Common Questions
    "Can I use the software I download from Creative Cloud on more than one machine?
    Yes. Creative Cloud desktop applications can be downloaded and installed on multiple computers, regardless of operating system. However, activation is limited to two machines per individual associated with the membership. See the terms of use for more information. Learn how to deactivate a Creative Cloud license on a machine."

  • How to set value for trim and bleed using jsx script?

    I have tried using bleedoffsetRect but somehow it is not working. Can anybody please help me on how to set value for trim and bleed using jsx script? Any example will be highly appreciated.
    Following is the code I am trying with:
    var _saveName = new File ( root_path +_strFileName+".pdf");
        var _saveOpts = new PDFSaveOptions();
        _saveOpts.printerResolution = 300; 
        var bleedarray = new Array();
         bleedarray[0] =9.00;
         bleedarray[1]=9.00;
         bleedarray[2]=9.00;
         bleedarray[3]=9.00;    
        _saveOpts.bleedOffsetRect = bleedarray;

    I would expect although I've not actually tried this for the bleed off set box to be larger than the artbaord and the first two values to be negative or 0…
    var bleedarray = new Array(-9,-9,artboard.width+9,artboard.height+9);
    Where 'artboard.width' & 'artboard.height' you will have calculated from your file. An Array(9,9,9,9); would not constitute any boxes bounds.

  • Hi i dont have a wifi broadband n i just bought the new ipod touch can anyone tell me how 2 download apps for my ipod without using wifi

    hi i dont have a wifi broadband n i just bought the new ipod touch can anyone tell me how 2 download apps for my ipod without using wifi

    Download the apps on your syncing computer and then sync to the iPod. Note that you can only sync apps for the one syncing computer you use with the iPod. You can manage music and videos among different computer.

  • WRT54GL V 1.1 : how to reserve IP for specific MAC address using DHCP

    My !free! made in China router have this functionality. And yet I have been banging my head with this new reasonably expensive wireless router from Linksys. Anyway I lug my notebook around. I need my home router to be able to automatically configure notebook IP address using DHCP. At the same time I need the ip given by home router through DHCP to be the same IP all the time. So "static" ip is not the solution. Alternative "static" ip is also not a solution. Anything with the word "static" in it is not a solution. I know about third party firmware (wrt or tomato) and I know WRT54GL can be flashed with this third party firware. But I'm not going to void my warranty. This will be my last option but not the solution that I seek. I would like to know how to reserve ip for specific mac address using DHCP for WRT54GL V1.1. If this version have no way to make such configuration, I would like to know if there is official firmware upgrade that address this. Thanks in advance!

    LDK-Anc wrote:
    Tonik - For the life of me, I cannot find DHCP Reservation on the WRT300N. I'm currently configuring one and it would be really useful if I could fine it. Maybe LinkSys calls it something else, but I don't really see anything resembling it. Help!
    Maybe these could help. (Images extracted from the User Guide)
    Setup tab: Basic Setup
    DHCP Reservation
    Message Edited by denman_v2 on 03-25-2008 05:11 PM

  • How do two users on the same iMac use the same iPhoto library?

    How do two seperate users on an Imac, use the same iphoto library? 

    See iTunes: How to share music between different user accounts on a single computer.
    tt2

  • Compare two XMLElements for semantical equality

    I rewrote a statement that generates XML from our database and I need to check if it produces the same result as the old statement. However, for some reason, the new statement generates a certain empty element as <FOO/> while the old statement generates a <FOO></FOO>. The strange thing is, that the tag is generated by a substatement that definitely has not changed at all.
    This wouldn't be a problem if I could compare the two XMLElements for semantical equality but I couldn't find an appropriate function.

    I didn't change the database version, both versions of my XML generating queries run on the same schema on the same database. I think it doesn't make sense to post the whole queries since they are really huge. So I will try to point out the relevant part:
    I have a rather complex query that generates an XML document using SQL/XML. I refactored that query to avoid code redundancies and to make it more readable. The output of the refactored query is the same as that of the old query, except for the representation of that empty tag.The empty tag is generated by a subquery that is called by the refactored query. The subquery has not changed at all and it is called with the same parameters as before.
    I don't know if there is a way to take explicit control of how empty tags should be represented. But it seems that the representation that the DBMS chooses by default is practically not predictablae.

Maybe you are looking for

  • END ROUTINE clarification

    Hi, I have seen below text in help Only fields that have a rule in the transformation are transferred from the end routine http://help.sap.com/saphelp_nw70/helpdata/en/20/a894ed07e75648ba5cf7c876430589/frameset.htm what does it mean..for ex if i popu

  • Out of sync in Final Cut Pro 6

    I shot a musical audition in SD on a Panasonic 3CCD camera. I'm using Log and Capture in FCP6 on my MacBook Pro, 2.4GHz Intel Core 2 Duo (4 GB 667 MHz DDR2 SDRAM). I wanted this audition separate from others I've filmed, so I copied my previous seque

  • Not able to connect RAC database

    hi all i am using oracle 10.2 RAC on suse enterprse linux server 10.1 from node 1 i am able to connect database but from node 2 i m not able to connect.. when try to connect system/test.. its hang and didnt dispaly any error messg.. even yesterday i

  • Syncing contacts from ipad to itunes

    I would like to sync contacts from ipad to my iphone and itunes

  • How will u transport Xi scenario from development to testing?

    How will u transport Xi scenario from development to testing?