Hi Friends,
I need your help. I have written this code to get the transliteration in Java. BUt it gives me incorrect output for > 4 words... <%@ page language = "java" %> <%@ page import = "java.sql.*" %> <%@ page import = "java.util.*" %> <%@ page import = "java.io.*" %> <%@ page import="java.lang.*" %> <%@ page import="java.net.*" %> <%@ page import="java.nio.*" %> <%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %> <% try { out.println("Hello"); Properties systemSettings = System.getProperties(); systemSettings.put("*********", "****************"); systemSettings.put("http.proxyPort", "****"); systemSettings.put("sun.net.client.defaultConnectTimeout", "10000"); systemSettings.put("sun.net.client.defaultReadTimeout", "10000"); out.println("Properties Set"); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication ("*", "****".toCharArray()); // specify ur user name password of iitb login } }); System.setProperties(systemSettings); out.println("After Authentication & Properties Settings"); //the input to google api //String str = "tlqt=1&langpair=en|hi&text=sdffdgdf sdfsd qwewq adfasw qeqewq asdfqw3eeeeww adas adasdasd adasds &&tl_app=1"; //http://www.google.com/transliterate/indic?tlqt=1&langpair=en| hi&text=sdfsd%20qwewq%20adfasw%20qeqewq%20asdfqw3eeeeww%20adas %20adasdasd&&tl_app=1 String str = "tlqt=1&langpair=en|hi&text=sdfsd%20qwewq%20adfasw %20qeqewq%20asdfqw3eeeeww%20adas%20adasdasd&&tl_app=1"; String stringToReverse = ""; try { stringToReverse = "http://www.google.com/transliterate/ indic?" + URLEncoder.encode(str, "UTF-8"); } catch(Exception ex) {} out.println(stringToReverse); URL url = new URL(stringToReverse); URLConnection connection = url.openConnection(); //connection.setDoOutput(false); BufferedReader in = new BufferedReader( new InputStreamReader ( connection.getInputStream())); String decodedString; String tempstr = ""; out.println("Decoded String Like->"+ URLDecoder.decode ("\u0905\u092E \u093F\u0924\u093E\u092C\u091A\u0928","UTF-8") + "<br>") ; while ((decodedString = in.readLine()) != null) { tempstr = tempstr + decodedString; } out.println(tempstr); //code ends. String[] strval = tempstr.split("ew"); out.println("Length="+strval.length + "<br>"); //loop through all the values of the string array. for ( int j=0; j < strval.length; j++ ) { String val = strval[j]; out.println("<br>j=" + j + " & Array Val="+val+ "<br>"); //next check for ":" sign. if ( val.contains(":") ) { out.println(" It has colon"); //check for first comma in this string. /*int commapos = val.indexOf(","); out.println(" Pos of comma is "+ commapos + "<br>"); */ String[] strval2 = val.split(","); String strval3 = ""; for (int k=0; k < strval2.length; k++ ) { out.println("<br>k=" + k + " & Comma Array Val="+ strval2[k] + "<br>"); //now replace all " and ":" characters. strval3 = strval2[k]; strval3 = strval3.replaceAll("\"",""); strval3 = strval3.replaceAll(":",""); out.println("<br>k=" + k + " & New Comma Array Val="+ strval3 + "<br>"); out.println("Final value of ew="+strval3);//value of ew obtained. } //code to get values of //next get the substring till first "," } } in.close(); } catch(Exception ex) { out.println("Exception->"+ex); PrintWriter pw = response.getWriter(); ex.printStackTrace(pw); } %> ---------------------------------------------------------------------------------------- This code just stores value in string variable which I can parse for my output.. IS there anything that I have missed or is incorrect. Please help... I am not using Eclipse..Can I use GWT toolkit to get this done correctly. Regards, Jitesh Dundas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---