Java Utililty Methods Path Encode

List of utility methods to do Path Encode

Description

The list of methods to do Path Encode are organized into topic(s).

Method

StringencodePath(String path)
Constructs an encoded version of the specified path string suitable for use in the construction of a URL.
StringBuffer sb = new StringBuffer();
int n = path.length();
for (int i = 0; i < n; i++) {
    char c = path.charAt(i);
    if (c == File.separatorChar)
        sb.append('/');
    else {
        if (c <= 0x007F) {
...
StringencodePath(String path)
encode Path
int maxBytesPerChar = 10;
StringBuffer rewrittenPath = new StringBuffer(path.length());
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
OutputStreamWriter writer;
try {
    writer = new OutputStreamWriter(buf, "UTF8");
} catch (Exception e) {
    e.printStackTrace();
...
StringencodePath(String path)
Constructs an encoded version of the specified path string suitable for use in the construction of a URL.
return encodePath(path, true);
StringencodePath(String path, boolean encodeSlash, String charset)
Encode a path suitable for use in a URI.
StringBuffer buffer = new StringBuffer();
byte encoded[];
try {
    if (charset == null)
        encoded = path.getBytes();
    else
        encoded = path.getBytes(charset);
    for (int x = 0; x < encoded.length; x++) {
...
StringencodePath(String url)
URL encodes the path.
StringBuilder strbuf = new StringBuilder();
String sub = url;
String result = null;
if (sub != null) {
    if (sub.startsWith("file://")) {
        sub = sub.substring("file://".length());
    StringTokenizer strtok = new StringTokenizer(sub, "/");
...
StringencodePathSegment(final String pathSegment)
Encodes a string to be a valid path segment, which means it can contain PCHAR* only (do not put path parameters or they will be escaped.
try {
    return encodePart(pathSegment, "UTF-8", PATH_SEGMENT);
} catch (final UnsupportedEncodingException e) {
    throw new RuntimeException(e);