[an error occurred while processing this directive]

EncoderTest

                         

This is a simple program of java network and supports the java.net package. Here, we have defined the class named EncoderTest.java. This class contains static methods for converting a String to the application-urlencoded MIME format.

The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same. And the space characters ".", "-", "*", and "_" remain the same. The encoding string supports to the space character is converted into a plus sign +. All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. 


Here is the code of this program:

import java.net.*;
import java.net.URLEncoder;

public class EncoderTest{
  public static void main(String[] args){
    System.out.println(URLEncoder.encode("This string has spaces"));
    System.out.println(URLEncoder.encode("This*string*has*stars"));
    System.out.println(URLEncoder.encode("This%string%has%percent%signs"));
    System.out.println(URLEncoder.encode("This.is.first.program.of.encoder"));
    System.out.println(URLEncoder.encode("This/is/simple/Encoder/test/program"));
  }
}


Output of this program:

C:\amar>javac EncoderTest.java

C:\amar>java EncoderTest
This+string+has+spaces
This*string*has*stars
This%25string%25has%25percent%25signs
This.is.first.program.of.encoder
This%2Fis%2Fsimple%2FEncoder%2Ftest%2Fprogram

C:\amar>

 

Download of this program.

                         

[an error occurred while processing this directive]