Getting the first part of a URL

I have a Example URL of -
http://www.red.co.uk/blue/white.html
I need only the following -
http://www.red.co.uk/blue/
That is the URL without the page, but all the directories.
getURL() returns the full URL - http://www.red.co.uk/blue/white.html
getFile() returns - /blue/white.html
getHost() returns - www.red.co.uk
Is there a nice easy way to do this?

Try this:      1 import java.net.URL;
      2 import java.net.MalformedURLException;
      3
      4 public class URLTest {
      5     public static void main(String[] args) throws MalformedURLException
      6     {
      7         URL url = new URL("http://www.red.co.uk/blue/white.html");
      8         URL newUrl = new URL(url, ".");
      9
     10         System.out.println(url);
     11         System.out.println(newUrl);
     12     }
     13 }The output is the desiredhttp://www.red.co.uk/blue/white.html
http://www.red.co.uk/blue/

Similar Messages

  • Using Overdrive Media to down load a book from the library it starts ok but stops near the end of the first part I get no indication on ipod of download

    When using Overdrive Media to down load a book from the library it starts ok but stops near the end of the first part. I get no indication on the ipod of the book downloading. Is this a operating error or posable failure of the I pod.?

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar
    The missing apps could have been done by setting the Restrictions that can hid those apps. If the backup was made with those retrictions set the the Restrictions are also restored.
    Thus, if you get it to work restore to factory settings/new iPod, not from backup                               
    You can redownload most iTunes purchases by:        
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Anytime I try to print in Firefox a Microsoft KB article that is 1 page, I always only get the first page.

    Anytime I print any Microsoft KB article, I only get the first page worth of text. This is very troubling because the articles are typically long, and I only get 1 page. The second page always comes out blank (even though in IE it will print out multiple pages with all the text).
    My specific example today is listed in the URL below. This example will only print to the "DIR" command, I don't get the full page printed out.
    Anyone else have this problem? Anyone have a resolution? I hate having to hit up IE just to print a single article.
    I updated to FF 8.01 just to make sure, and I have tried different printers and even computers, to no avail. Even the print preview has the issue, only the first page worth of text is printed and the second page is always blank (even if there are 3, 4, 5, etc pages of data to be printed).
    I have also tried the Firefox Menu -> Print command, and the "on-page" print command. I have seen moderate success with highlighting all the text that I want to print and going to "Print-Selection" but it is ugly.
    Any feedback or assistance is greatly appreciated.

    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "'Start in Safe Mode"''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Getting the first row for each group

    Hi Everyone,
    I have a query which returns a number of rows, all of which are valid. What I need to do is to get the first row for each group and work with those records.
    For example ...
    client flight startairport destairport stops
    A fl123 LGW BKK 2
    A fl124 LHR BKK 5
    B fl432 LGW XYZ 7
    B fl432 MAN ABC 8
    .... etc.
    I would need to return one row for Client A and one row for Client B (etc.) but find that I can't use the MIN function because it would return the MIN value for each column (i.e. mix up the rows). I also can use the rownum=1 because this would only return one row rather than one row per group (i.e. per client).
    I have been investigating and most postings seem to say that it needs a second query to look up the first row for each grouping. This is a solution which would not really be practical because my query is already quite complex and incorporating duplicate subqueries would just make the whole thing much to cumbersome.
    So what I really new is a "MIN by group" or a "TOP by group" or a "ROWNUM=1 by group" function.
    Can anyone help me with this? I'm sure that there must be a command to handle this.
    Regards and any thanks,
    Alan Searle
    Cologne, Germany

    Something like this:
    select *
    from (
       select table1.*
       row_number() over (partition by col1, col2 order by col3, col4) rn
       from table1
    where rn = 1In the "partition by" clause you place what you normally would "group by".
    In the "order by" clause you define which will have row_number = 1.
    Edit:
    PS. The [url http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions004.htm#i81407]docs have more examples on using analytical functions ;-)
    Edited by: Kim Berg Hansen on Sep 16, 2011 10:46 AM

  • Get the first and the last date of a week

    Hi all
    I need to get the first and the last date of a specific week.
    I need a function that returns two date passing it just one date.
    The function has to calculate the first and the last date of the week of the argument date.
    hope to be clear
    regards

    goiters,
    I need to get the first and the last date of a specific week.Yup, and what's the first day of the week in your part of the world, is it Sunday or Monday?
    I need a function that returns two date passing it just one date.No you don't, just add 7 days to the start of the week.
    hope to be clearWell, you can hope.
    Keith.
    Message was edited by: corlettk - now I hope to clear ;-)

  • Bug: WebcamPublisher always gets the first camera

    Hi,
    It seems WebcamPublisher always gets the first camera in the list, no matter what camera is chosen by the end user. Beside this, at some point in WebcamPublisher, it has been hardcoded to use Apple's isight camera, if no cam was found:
    if( _camera==null){
    // If there is no camera , create it and attach it to the stream
    if (_cameraNameIndex==null && Capabilities.os.indexOf("Mac OS 1")!=-1) {
    // it's silly season - let's try to detect iSight cams, if nothing gets specified
    var l:int = Camera.names.length;
    for (var i:int=0; i<l; i++) {
    if (Camera.names[i]==ISIGHT_NAME) {
    _cameraNameIndex = i+"";
    break;
    Could someone from the lccs development team respond about the quality of code in lccs library, and whether the lib is supposed to be ready for production use. I have asked this in my previous post, but not response has been given so far.
    Aureliano

    Hi,
    The WebcamPublisher by default, selects what is returned by the player's Camera.getCamera() API i.e. the default camera player could detect. This is when _cameraNameIndex is null. If you want, you can set the cameraNameIndex property i.e. the camera name string( you can do that by getting Camera.names API in flash player) before starting the Webcam. It will then take the camera you mentioned.
    In fact we have one of our real life application that uses this property to set the camera you want to see.
    You can always use your handler to the selected value of camera in SecurityPanel.CAMERA and set it to the cameraNameIndex property.
    And lastly, yes our code is production ready. We have our own commercial apps as well as enterprises using it for building application. If you want to change any part of the code, you are free to do so.
    Hope this helps
    Thanks
    Hironmay Basu

  • How can I print Double A4 with HP Officejet 6500? I only get the first page...

    I try to print a large photo in "landscape" Double A4 with my HP Officejet 6500.
    I can select "Double A4" to print but I only get the first page. So I only have  half a photo.
    What should I do?

    chris
    You can not attach a multi-page .pdf document to Pages.
    Just create a folder in which you enclose both your Pages letter and the .pdf.
    Peter

  • How to get the first and the last record of every month within a time range in sql

    I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
    where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
    SELECT PurOrderNum,
    OrderDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to get the first day in the month from a domain date ?

    Hi,
    I like to know how to get the first day in the month from a domain date?
    Thanks
    Stephen

    Hi Gokul...
    Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
    Its similar to the above one but instead of writing case statement you can achive the following.
    data : w_res type i,
             w_data type d,
    w_res = w_date mod 7.
    w_date = w_date - w_res.
    write w_date.
    This works.
    Regards,
    Siddarth

  • How  to  get the FIRST DAY OF THE CURRENT MONTH

    how to get the FIRST DAY OF THE CURRENT MONTH in oracle 9i.
    plzzzzz send immedaily.advance thanks

    TEST@test SQL> select trunc(sysdate,'MON') from dual;
    TRUNC(SYS
    01-OCT-06
    TEST@test SQL>                                  

  • I purchased a album and only the first part of each song plays, even though the entire length is listed  in the file properities. Any Ideas?

    I purchased a album and only the first part of each song plays, even though the entire length is listed  in the file properities. Any Ideas?

    Assuming you are in a region where you are allowed to redownload your past purchases, delete the current copies from your iTunes library and then download again from your purchased history. If the problem persists, or that facility is not available in your region, contact the iTunes Store support staff through the report a problem links in your account history.
    tt2

  • Apple Mail - how to get the first word in a sentence to auto-capitalize

    How to get the first word in a sentence to auto-capitalize
    Anwar

    something to look forward to then, because we get used not to use our shift button any more, since iPhone and iPad do it for us. entourage and other ms stuff do it. pages does it too now (put it on in the auto-correct in preferences). bizarre however some loose the capitalization when you copy the text. pages to stickies or mail does not. that's good !

  • I am using a new Mini Mac via HDMI, I get the First gray screen then nothing else

    I am a First time user of a Mac and I've gone toturn it on fr the first time today, i conected it to a HD ready LCD tv via HDMI and get the first gray 'loading' screen then an 'English' over the speekers then nothing else
    Any help would be apreciated

    Make sure the TV's menu is actually set to connect to that HDMI port.
    Make sure the TV is 1080p and is setup to use that resolution on the HDMI port in question.
    Try zapping the PRAM, by following these instructions:
    http://support.apple.com/kb/ht1379

  • How can I view a PDF file on my IPad? I only get the first page.

    How can I view a PDF file from my Ipad, both in email and Internet links? I only get the first page.

    Support for viewing PDFs in emails and web-pages is built in to the iPad. You need not have bought an app for that.
    There are PDF apps that provide more features than the built-in functionality, but for basic viewing of multi-page PDFs no app is required.

  • Previously, when I got a message notification on my iPhone, I could see the first part of the text. Now it just says "iMessage".

    Previously, when I got a message notification on my iPhone home screen, I could see the first part of the text. Now it just says "iMessage". How can I change this?

    Settings > Notifications > Messages > Show Preview > On.
    Also, check other settings on this screen. 
    Notifications can be a little confusing... this may help... http://www.imore.com/notification-center-ultimate-guide

Maybe you are looking for