public static void escapeUriPathSegment(final String text, final Writer writer, final String encoding)
            throws IOException {

        if (writer == null) {
            throw new IllegalArgumentException("Argument 'writer' cannot be null");
        }

        if (encoding == null) {
            throw new IllegalArgumentException("Argument 'encoding' cannot be null");
        }

        UriEscapeUtil.escape(new InternalStringReader(text), writer, UriEscapeUtil.UriEscapeType.PATH_SEGMENT, encoding);

    }
public static void escapeUriPathSegment ( final String text , final Writer writer , final String encoding ) throws IOException { if ( writer == null ) { throw new IllegalArgumentException ( "Argument 'writer' cannot be null" ) ; } if ( encoding == null ) { throw new IllegalArgumentException ( "Argument 'encoding' cannot be null" ) ; } UriEscapeUtil . escape ( new InternalStringReader ( text ) , writer , UriEscapeUtil . UriEscapeType . PATH_SEGMENT , encoding ) ; }
<p>
Perform am URI path segment <strong>escape</strong> operation
on a <tt>String</tt> input, writing results to a <tt>Writer</tt>.
</p>
<p>
The following are the only allowed chars in an URI path segment (will not be escaped):
</p>
<ul>
<li><tt>A-Z a-z 0-9</tt></li>
<li><tt>- . _ ~</tt></li>
<li><tt>! $ &amp; ' ( ) * + , ; =</tt></li>
<li><tt>: @</tt></li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in <tt>%HH</tt> syntax, being <tt>HH</tt> the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>

@param text the <tt>String</tt> to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param encoding the encoding to be used for escaping.
@throws IOException if an input/output exception occurs

@since 1.1.2