Java URL Encode encodeUri(String url)

Here you can find the source of encodeUri(String url)

Description

encode Uri

License

Open Source License

Declaration

public final static String encodeUri(String url) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {

    public final static String encodeUri(String url) throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        DataOutputStream dout = new DataOutputStream(bout);
        dout.writeUTF(url);//from   w w w .  java 2s.  co  m
        byte[] byteUrl = bout.toByteArray();
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < byteUrl.length; i++) {
            buf.append(byteUrl[i] + "|");
        }
        dout.close();
        bout.close();
        return buf.toString();
    }
}

Related

  1. encode(String value, String encoding)
  2. encodeArray(final String[] val)
  3. encodeForUrl(final String s)
  4. encodeSrcUrl(String fullUri)
  5. encodeStringURL(String str)
  6. encodeURIComponent(String input)
  7. encodeURL(BitSet urlsafe, byte[] bytes)
  8. encodeUrl(final String input)
  9. encodeURL(String s)