Here you can find the source of stringToURI(String[] str)
Parameter | Description |
---|---|
str | The string array to be parsed into an URI array. |
Parameter | Description |
---|---|
IllegalArgumentException | If any string in str violates RFC 2396. |
public static URI[] stringToURI(String[] str)
//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 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; } }