Code to parse string to retrieve URLs

Hi all,
I need a code to parse a string to get all URLs in that string. Pls help me.
Thank you

This is basic string coding. Read http://java.sun.com/docs/books/tutorial/java/data/strings.html

Similar Messages

  • Code to parse the XML stored in a XMLTYPE field in database

    Hi All,
    Please can someone forward me the code to parse the XML retrieved from the oracle database. I want to parse the whole xml, any node any attribute and store the extracted values in database. For example:
    <mail>
    <mailing_list name="test1">
    <mailing_list_users>
    <user email="[email protected]" address="abcd" />
    <user email="[email protected]" address="abcdef" />
    </mailing_list_users>
    </mailing_list>
    <mailing_list name="test2">
    <mailing_list_users>
    <user email="[email protected]" address="abcd1" />
    <user email="[email protected]" address="abcdef1" />
    </mailing_list_users>
    </mailing_list>
    </mail>
    In this example, i want to loop thru all the mailing lists to extract therir values and under each mailing lists i want to loop thru all the users and their details.
    I require this urgently. Any help will be appreciated.

    I am not sure if this is the correct way to do it but I found such class from my old codes:
    import java.util.*;
    * class for parsing strange value of time to "normal" view
    public class NumericToTime
         GregorianCalendar gc = null;
         StringTokenizer st = null;
         int days, hours, minutes, seconds, milliseconds;
         float fract;
         public NumericToTime(String str)
              try
                   gc = new GregorianCalendar(1900,0,0);
                   st = new StringTokenizer(str, ".");
                   days = Integer.parseInt(st.nextToken());
                   Float f = new Float("0." + st.nextToken());
                   fract = f.floatValue();
              catch(NoSuchElementException e)
                   fract = 0.0f;
         * method which calculate time
         public void calculateTime()
              float h, m, s;
              gc.add(GregorianCalendar.DATE, days-1);//days-1 MS'i fenomeenil baseeruv "patch"
              h = (float)(24.0*fract); hours = (int)h;
              gc.set(GregorianCalendar.HOUR, hours);
              m = (float)(60.0*(h - (float)hours)); minutes = (int)m;
              gc.set(GregorianCalendar.MINUTE, minutes);
              s = (float)(60.0*(m - (float)minutes)); seconds = (int)s;
              gc.set(GregorianCalendar.SECOND, seconds);
              milliseconds = (int)(1000.0*(s - (float)seconds));
              gc.set(GregorianCalendar.MILLISECOND, milliseconds);
         * method which return time value as Date object
         public Date getTime() {
              return gc.getTime();
    Hope this is some help for You!

  • Retrieve url parameters

    Hi All
    I need to retrieve all the parameters of the url, for example if the URL looks like
    http://www.mydomain.com/MyApp.html#firstName=Nick;lastName=Danger
    (example used: http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_5.html )
    Anyway, the code to extract the parameters looks like
    then the parameters are extracted like
            private function init(e:Event):void {
                bm = BrowserManager.getInstance();               
                bm.init("", "Welcome!");
                /* The following code will parse a URL that passes firstName and lastName as
                   query string parameters after the "#" sign; for example:
                   http://www.mydomain.com/MyApp.html#firstName=Nick&lastName=Danger */
                var o:Object = URLUtil.stringToObject(bm.fragment, "&");               
                fName = o.firstName;
                lName = o.lastName;               
    However, the fName and lName remain empty. Any suggestion how to retrieve URL parameters ?
    cheers
    Luca

    Hi scaljeri...try this...it worked for me last week:
    protected function readQueryString():String{
              var urlParams:Dictionary = new Dictionary();
              if (ExternalInterface.available)
                   var fullUrl:String = ExternalInterface.call('eval', 'document.location.href');
                   var paramStr:String = fullUrl.split('?')[1];
                   if (paramStr != null)
                        var params:Array = paramStr.split('&');
                        var s:String;
                        for (var i:int=0; i < params.length; i++)
                             var kv:Array = params[i].split('=');
                             urlParams[kv[0]] = kv[1];
                             s =  kv[1];
                   return s;
              return null;
    yellow

  • Code to parse java code

    anyone know where we can get the code that parses the Java code that we put here ?
    i was thinking it would be a good base to use as a pre-compiler project - so we can have pre-compiler flags like in c - say to include logging ...
    example of the code formatting at work:
    class Rename{
      * Rename a file from command line,
      * args[0] is the existing file name
      * args[1] is the new file name
      public static void main (String[] args)
       try{
        java.io.File fExisting = new java.io.File(args[0]);   
        java.io.File fNew = new java.io.File(args[1]);
        if(!fExisting.exists()){
         System.out.println("Rename will fail as source does not  exist. Exiting");
         return;
        if(fNew.exists()){
         System.out.println("Rename might fail as target already exits - delete it first ");
        System.out.println("attempt rename :\n" + fExisting.getAbsolutePath() + "\n to:\n" + fNew.getAbsolutePath() );
        boolean b = fExisting.renameTo(fNew);
        if(b){
         System.out.println("Done ok ");
        }else{
         System.out.println("rename failed ");
       }catch(Throwable e){
        System.out.println("Could not rename " + e);
        e.printStackTrace();
    synchrozied (objSync){
    try{
      while(bPause){
       Thread.sleep(250);  
      }catch(Throwable e){
       //can ignore
    }would be a nice source forge project - unless there is already one out there

    Try this link from Javaranch - I started reading it, but got distracted and did not pursue it very far. It's about JFlex parser and an example of parsing java code is provided or linked to:
    http://www.javaranch.com/journal/2008/04/Journal200804.jsp#a4
    Look for the section titled: "Handling Uncommon File Formats - Introducing Lexers"

  • Parsing String

    i have problem to parse string to document
    i have string like this str = "<root><data>1</data><data>2</data><root>";
    how to parse this string in docoment xml

    import java.io.*;
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.output.*;
    public class PrettyPrinter {
       public static void main(String[] args) {
            // Assume filename argument
            String filename = args[0];
            try {
                // Build the document with SAX and Xerces, no validation
                SAXBuilder builder = new SAXBuilder();
                // Create the document
                Document doc = builder.build(new File(filename));
                // Output the document, use standard formatter
                XMLOutputter fmt = new XMLOutputter();
                fmt.output(doc, System.out);
            } catch (Exception e) {
                e.printStackTrace();
    }The above code is taken directly from
    http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom-p2.html
    u don't have to use Factories, this is what is said in that excerpt, it is very easy to use, and it is said that 80 % of the xml work can be done with 20 % or less work using JDOM.
    n joy ....
    </ksenji>

  • How could i parse string and link its model with my files in eclipse project?

    How could i parse string and link its model with my files in eclipse project?, as i read that we dont have to use standalone mode while working with eclipse projects.
    Example of what i want to do:
    I have file1.dsl in my project which contains some statements but the declaration of these statements are not in another file, i need to put them only in my code

    Hi Stefan,
    I have eclipse project contains 2 files, file1.dsl and file2.dsl, you can see the contents of the files below.
    file1.dsl contains some statements as shown below and file2.dsl contains the declarations of the variables. (like in C++ or Java we have declarations and usage)
    At this step file1.dsl and file2.dsl will be parsed successfully without any errors.
    Lets imagine that we will delete this project and will create another one and the new project will contain only file1.dsl (which contains the usage)
    At this step this file (file1.dsl) will contains some errors after parsing it, because we are using variables without declarations.
    So what i need is to parse the content of file2.dsl directly without adding this file to the project.
    I need to add the content of file2.dsl directly as a string in the code and parse it. just like that ( "int a;int b;" )
    And link file1.dsl with the model generated after parsing my string
    file1.dsl
    a++;
    b++;
    file2.dsl
    int a;
    int b;
    Thanks

  • Trouble parsing string

    I need to parse strings in the format "City State
    Abbreviation Zipcode" (ie "Glenview, IL 60062") to seperate them as
    their own variables. Problem is that sometimes there is a comma
    after city, sometimes not, so I've resorted to REfind to seperate
    the string. Here's the snippet, "city" is the entire string I
    mentioned above. The problem is that the refind I use seems to be
    returning 0. I'm trying to find the two capital letters that
    designate the state abbeviation.
    <cfif city neq ''>
    <cfset crpos = refind("[:upper:][:upper:]",city) >
    <cfset zip = trim(right(city,len(city)-crpos))>
    <cfset citystate = trim(left(city,crpos)) >
    <cfset newpos = find("#chr(32)#",citystate) >
    <cfset state =
    trim(right(citystate,len(citystate)-newpos)) >
    <cfset actualcity =
    trim(left(citystate,len(citystate)-newPos)) >
    </cfif>

    I probably should mention some explaination about what the
    regular expression is doing:
    Note: Groups are RegExp statements surrounded by ()
    Group 1: Combination of Letters and Spaces (e.g. City Name)
    optional comma and (required) space
    Group 2: 2 Character upper case state code (State Code) (note
    - depending on your source, state codes may not always be upper
    case)
    (required) space
    Group 3: 5 digit string (e.g. Zip Code) (note - again,
    depending on your source, you may be getting 5 digit zip + 4 or
    even non-us zip codes that may involve alpha characters.)
    The replace function is using back references to refer to the
    text matched by group 1,2 and 3.

  • How to generate GUI code from parsed XML file?

    hai,
    I have to generate GUI code after parsing any configuration XML file as input.Now i have parsed my XML file and got its attributed and i want to get some idea of how to map the parsed XML attributes to the java code to build GUI code.

    Hello,
    1. I like to create data type from a XML file structure, which contains the data structure ?
    XML fields will need to be taken note of to see which is repeating or not. You can also load the XML into a third-party tool such as Altova XML Spy and then generate an XSD from there. You will need to import the XSDs into PI under external definitions. However, this does not guarantee business interoperability, as such, it is always best to ask the provider for the XSDs or WSDL. It will also save you a lot of time from guessing which fields are needed or not.
    2. How to create custom node function in graphical mapping editor ?
    In your graphical mapping editor, on the lowest left corner, there is an icon there that says Create New Function. You must take into account their return types:
    1. Single Values = String
    2. Queue/Context (no return type) thus resultList is used.
    Hope this helps,
    Mark

  • How to retrieve URL in JSP

    Hi guys.
    Does somebody knows how can I retrieve URL in JSP?
    I need to know if the user came to my page via www.MySite.com/page.jsp or 128.951.0.0/page.jsp
    Thanks in advance,
    and have a nice day.
    Vadim.

    String URL = "http://"+request.getServerName()+":"+request.getServerPort()+request.getRequestURI()+(request.getQueryString() != null ? "?"+request.getQueryString() : "" )

  • Java.lang.NoSuchMethodError: com.sun.xml.ws.util.JAXWSUtils.getEncodedURL(Ljava/lang/String;)Ljava/net/URL;

    java.lang.NoSuchMethodError: com.sun.xml.ws.util.JAXWSUtils.getEncodedURL(Ljava/lang/String;)Ljava/net/URL.
    Gettin exception while trying to execute clientGen from build.xml from eclipse using Oracle weblogic 10.3 server.
    I tried with both jars jaxws-rt-2.1.4 and jaxws-rt-2.1.3
    Regards,
    Manish

    along with wlfullclient.jar please add wseeclient.jar
    Copy the file WL_HOME/server/lib/wseeclient.zip from the computer hosting WebLogic Server to the client computer( where WL_HOME refers to the WebLogic Server installation directory, such as /Oracle/Middleware/wlserver_12.1)
    Unzip the wseeclient.zip file into the appropriate directory. For example, you might unzip the file into a directory that contains other classes used by your client application.
    Add the wseeclient.jar file (unzipped from the wseeclient.zip file) to your CLASSPATH.
    Note:
    Also be sure that your CLASSPATH includes the JAR file that contains the Ant classes (ant.jar). This JAR file is typically located in the lib directory of the Ant distribution.
    http://docs.oracle.com/cd/E24329_01/web.1211/e24967/client.htm#WSRPC214
    Regards,
    Sunil P

  • How to pass a Vector as a Query String to a URL

    is there a way to pass a vector as a query string in a URL in Java. If so how?
    thanks in advance

    Yeah may need some more detail, but if you are trying to pass the Vector object itself from one JSP/Servlet to another, you can simply put the object in one of the scopes like session or request then forward page on.
    e.g.
    FirstServletVector things = new Vector();
    things.add("one thing");
    things.add("another thing");
    request.setAttribute("objThings",things);
    getServletContext().getRequestDispatcher("/NextServlet").forward(request, response);SecondServletVector things = new Vector();
    Object o = request.getAttribute("objThings");
    if(o instanceOf Vector) things = (Vector)o;Hope that helps!!

  • Having problems parsing String to Date

    Hello,
    Could someone please explain to me why the following code snippet parses the day and year correctly but returns the month as January regardless of which date I supply?
    SimpleDateFormat format = new SimpleDateFormat("M/D/y");
    try { Date date = format.parse("5/5/2000"); }
    catch (ParseException e) {}          
    System.out.println(date.toString());
    // returns --> Wed Jan 05 00:00:00 PST 2000

    Refer to http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    > SimpleDateFormat format = new SimpleDateFormat("M/D/y");Capital 'D' indicates Day in year. So day 5 in your example refers to the fifth day in Jan. Use small 'd', which indicates Day in month ...
    Cheers

  • How to parse string to date in j2me?

    How to parse string to date in j2me?
    Please help me.

    Hi..
    String dyStr = "20";
    String mtStr = "1";
    String yrStr = "1999";
    Calendar cal = Calendar.getIntstance();
    int dy = Integer.parseInt(dyStr);
    int mt = Integer.parseInt(mtStr);
    int yr = Integer.parseInt(yrStr);
    cal.set(Calendar.DATE, dy);
    cal.set(Calendar.MONTH, mt);
    cal.set(Calendar.YEAR, yr);
    OK?

  • Split Function unable to parse string correctly

    Hi,
    I'm using split function to split string into multiple rows using comma "," as delimiter. In a string I have following values which are not parsed correctly as they have comma inside the values. 
    American Dawn, Inc.
    Battalian USA, Inc.
    Fria USA, Inc.
    Lazer, Inc.
    Mexilink Inc.
    Is there any other approach to fix this issue?
    Here is the split function Im using:
    CREATE Function [dbo].[fnSplit] (
    @List varchar(MAX), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(MAX) NULL 
    As 
    Begin 
    Declare @item varchar(MAX), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final
    delimiter 
    Select @List = @List + @Delimiter -- get position of
    first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos
    -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List)
    - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    Another user in this forum posted a split function that
    he wrote:
    CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
    RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
    AS
    BEGIN
    WHILE CHARINDEX(@delim,@string) > 0
    BEGIN
    INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
    SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
    END
    INSERT INTO @result (value) VALUES (@string)
    RETURN
    END
    GO
    Both of them are unable to parse above values incorrectly.
    FYI:  String is made of values that are selected
    by user in SSRS report. I think SSRS when combine values , put comma "," between multiple values.
    Any help or guidance would be appreciated.
    ZK

    duplicate of
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/820ac53c-ce25-4cc7-b828-5875a21d459d/split-function-unable-to-parse-string-correctly-in-ssrs-report?forum=sqlreportingservices
    please dont cross post
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Hi to parse String "x;y:z" in Core Java

    hi to parse String "x;y:z" in Core Java

    Deepak_A_L wrote:
    how do i parse a String "X;Y:Z" in java i.e the results of parsing the string
    String s = "X;Y:Z"
    in terms of ENGLISH LANGUAGE -->(X Semicolon Y Colon Z)
    should be the below o/p individual Strings.
    X
    Y
    Z
    how do i get the above output.????Split on a semi- or regular colon using String's split(String regex) method.

Maybe you are looking for

  • Combination of GR/IR Control not allowed for External Services-SRM PO error

    Hi All, SRM 5.0 ECS   R/3 4.6C We have a service PO, for which an error Combination of GR/IR Control not allowed for External Services is being displayed. The PO is in error in process at this moment. And is not in R/3 On SRM PO we have Confirm Perfo

  • Sub domains not working? help

    I recently got my server going with the dns being server.domain.ca I have domain.ca as primary zone server.domain.ca as Machine with IP 10.0.1.14 gallery.domain.ca as Machine with IP 10.0.1.14 I also have both domain.ca and server.domain.ca as a serv

  • Export gives a nasty red tint

    I need some help Please. I am trying to export a movie from Premiere CS3. The movie looks great when editing, previewing, etc. Whites are super white and color looks good. But the second I go to export, all my whites turn to pink and everything gets

  • Viewing files in Browser

    Dear all, We are runnig OAS 10.1.2 on solaris10 . We have a location in the OAS to store PDF documents. We are facing a strange issue in opening the PDF documents through web browser wither IE or firefox. for example : the URL : http://replica.mov.cm

  • The Zen Micro wired remote: Many raves, two small ra

    Just got my eagerly-anticipated white Zen Micro remote!! Here's my two cents: Pros: . Nice look that matches the design of the unit itself very well. 2. Definitely makes life easier in terms of controlling the unit while staying acti've. 3. Minimalis