Results 1 to 1 of 1
Thread: Url Encode
- 03-19-2010, 02:54 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 16
- Rep Power
- 0
Url Encode
So i have to display the amount of characters in my encoded string and i have to print the number of char in a line. I'm not sure where to put it into my code.
Java Code:import java.util.Scanner; public class URLencoder { Scanner in; String text, finished = ""; char temp; String noChange = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_-.*"; boolean found; public URLencoder(){ in = new Scanner(System.in); System.out.println("Enter text to be encoded:"); text = in.nextLine(); for(int counter = 0; counter < text.length(); counter++){ temp = text.charAt(counter); if(noChange.indexOf(temp) != -1){ finished += temp; }else{ if(Integer.toHexString(temp) == "20"){ finished += "+"; }else{ finished += "%" + Integer.toHexString(temp); } } } System.out.println(finished); } private static int length() { // TODO Auto-generated method stub return 0; } public static void main(String[] args) { new URLencoder(); } }
Similar Threads
-
Getting problem in UTF-8 Encode/Decode with Java
By sagarsway in forum Advanced JavaReplies: 2Last Post: 12-22-2008, 07:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks