Java URI Create stringToURI(String[] str)

Here you can find the source of stringToURI(String[] str)

Description

string To URI

License

Apache License

Parameter

Parameter Description
str The string array to be parsed into an URI array.

Exception

Parameter Description
IllegalArgumentException If any string in str violates RFC 2396.

Return

null if str is null, else the URI array equivalent to str.

Declaration

public static URI[] stringToURI(String[] str) 

Method Source Code

//package com.java2s;
/**/*from   w  ww .  j  av  a 2 s  . com*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    /**
     * @param str The string array to be parsed into an URI array.
     * @return <tt>null</tt> if str is <tt>null</tt>, else the URI array
     * equivalent to str.
     * @throws IllegalArgumentException If any string in str violates RFC&nbsp;2396.
     */
    public static URI[] stringToURI(String[] str) {
        if (str == null)
            return null;
        URI[] uris = new URI[str.length];
        for (int i = 0; i < str.length; i++) {
            try {
                uris[i] = new URI(str[i]);
            } catch (URISyntaxException ur) {
                throw new IllegalArgumentException("Failed to create uri for " + str[i], ur);
            }
        }
        return uris;
    }
}

Related

  1. getUriScheme(String address)
  2. getURIsPrettyPrint(final Collection uris)
  3. getURIStream(Object obj)
  4. getURIWithAuthority(URI uri, String authority)
  5. stringToUri(String fileString)
  6. uri(String host, String prefix, String path)
  7. uri(String path)
  8. uri(String str)
  9. uri(String uri)