Here you can find the source of unquote(String str)
Parameter | Description |
---|---|
str | quoted string |
Parameter | Description |
---|---|
IllegalArgumentException | if str doesn't have a leading ora trailing quotation mark |
NullPointerException | if str is null |
public static String unquote(String str)
//package com.java2s; public class Main { /**/*from w ww . j a v a 2 s. co m*/ * Returns the given quoted string without quotation marks. * * @param str quoted string * @return string without quotation marks * @throws IllegalArgumentException if {@code str} doesn't have a leading or * a trailing quotation mark * @throws NullPointerException if {@code str} is {@code null} */ public static String unquote(String str) { int lastIndex = str.length() - 1; if (lastIndex <= 0 || str.charAt(0) != '"' || str.charAt(lastIndex) != '"') { throw new IllegalArgumentException( "Attempting to unquote string without quotes!"); } return str.substring(1, lastIndex); } }