Java URI Create createDefaultName(final String uri)

Here you can find the source of createDefaultName(final String uri)

Description

create Default Name

License

Open Source License

Declaration

protected static String createDefaultName(final String uri) 

Method Source Code

//package com.java2s;
/**//  w  w  w.ja v a2 s. c o  m
 * 
 * Copyright (c) 2009 L3i ( http://l3i.univ-larochelle.fr ).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 * 
 */

import java.net.URISyntaxException;

public class Main {
    protected static String createDefaultName(final String uri) {
        String last = "";
        java.net.URI _uri = null;
        try {
            _uri = new java.net.URI(uri);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

        if (_uri != null) {
            final String _path = _uri.getPath();
            final String[] split = _path.split("/");
            if (split.length != 0) {
                last = split[split.length - 1];
                last.replaceAll("#", "");
                String[] split2 = last.split("[.]");
                if (split2.length > 0) {
                    last = split2[0];
                }
            }
        }

        return last;
    }
}

Related

  1. convertToURI(String value)
  2. create(final String uri)
  3. createAbsoluteURI(URI base, String uri)
  4. createConnection(final String uri, final String authValue)
  5. createDatastream(String registrationUri, String APIKey, String xmlDescription)
  6. createExtensionUri(final String ext)
  7. createURI()
  8. createUri(File file)
  9. createURI(final String file)