Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:44:32+00:00 2026-05-27T08:44:32+00:00

I am looking for a Java Library to validate a URL and to strip

  • 0

I am looking for a Java Library to validate a URL and to strip out certain parameters. The order of the parameters does not matter.

I was using regex but it is very slow. This method is called alot of times and needs to be fast.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:44:32+00:00Added an answer on May 27, 2026 at 8:44 am

    Apache Commons Validator includes UrlValidator class in commons-validator-1.3.1.jar. Following method is used to validate a given media resource locator (MRL) in VLCJ which is basically a URL. However, UrlValidator doesn’t work for file-based URL (with file:// scheme)

    /**
     * Get a media resource locator (MRL) with the following valid conditions: 
     * <br/>(1) a non-URI file link
     * <br/>(2) a URI link with "file:" scheme  
     * <br/>(3) a URI link with non-"file:" scheme
     * <br/>  
     * @param mrl media resource locator (MRL)
     * @return valid MRL; otherwise return null
     */
    private String validateMRL(final String mrl){
        String media = null;
        String newURI = mrl;
        URI uri = new File(mrl.trim()).toURI();
        try {
            String f = new File(mrl).getAbsolutePath();
            Outils.debugMessage("URI:" + f);
            if (FilenameUtils.equalsNormalized(newURI, f)){
                //this is a actual file link
                newURI = uri.toURL().toString();
                newURI = Outils.replaceAllString(newURI, "file:", "file://");
                Outils.debugMessage("NEW URI: " + newURI);
                media = newURI;
            }
            else if (!mrl.contains("file:")) {
                //this is not a file link or "file:" link
                if (mrl != null && mrl.length() > 0){
    
                    String[] schemes = {"http", "https", "rtsp", "rtp", "udp", "mms", "mmsh"};
    
                    UrlValidator urlValidator = new UrlValidator(schemes);
    
                    if (urlValidator.isValid(newURI))
                        media = mrl.trim();
                }
            }
            else {
                media = mrl;
            }
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Outils.debugMessage("CURRENT: " + media);       
        return media;
    }
    

    Sorry that this function doesn’t do any stripping of parameters (or I would say “schemes”). But, it can be done easily with replace() or substring()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a java library/class to parse clean URL's and get all
I'm looking for a Java library which can notify me about changes on the
I'm looking for a java library that works on the android that can download
I am looking for a Java library to do some initial spell checking /
So, I'm looking through a java library (JScience) after someone here thoughfully pointed me
I'm looking for a standalone Java library which allows me to parse LDAP style
I am looking for an open source library in Java for parsing and building
I am looking for a high-end graphics library for Java Standard Edition. I know
I'm looking for a well-maintained Java bytecode manipulation library with an intuitive API. There
I'm looking for a stanadlone application, script or library (better Java) to generate cab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.