[The Java Posse] Re: Java officially lags C
For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } See http://projectlombok.org/features/Cleanup.html for more information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlfor more information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlformore information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: OpenCL (or sort of) with Java?
Fabrizio Giudici wrote: mbien wrote: Hi Fabrizio, I 'll work on a JNI/GlueGen based OpenCL binding to Java as part of my bachelor thesis. If everything works well it will be an optional extension of JSR231 aka JOGL (and will also fully interoperate with JOGL). ...open source as soon i have something to show ;) Keep us informed, Michael! :-) for sure ;) -- Michael Bien http://michael-bien.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
I think you misunderstood Roel. I am aware of the method name argument override, I was merely exploring the different implementations and implications of these two ARM blocks. The JDK7 version would have to rely on a new interface Disposable being added to the libraries, as the abomination known as checked exceptions (IOException) once again gets in the way of simply using the existing Closable. Lombok couldn't care less what it's closing and could in fact be used as a C++ deconstructor. Correct? /Casper On 1 Sep., 15:47, Roel Spilker r.spil...@gmail.com wrote: Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlformore information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
Casper, You are correct. I just wanted the other readers to know that it is not limited to close. It is however limited to no-args methods. Roel On Sep 1, 4:10 pm, Casper Bang casper.b...@gmail.com wrote: I think you misunderstood Roel. I am aware of the method name argument override, I was merely exploring the different implementations and implications of these two ARM blocks. The JDK7 version would have to rely on a new interface Disposable being added to the libraries, as the abomination known as checked exceptions (IOException) once again gets in the way of simply using the existing Closable. Lombok couldn't care less what it's closing and could in fact be used as a C++ deconstructor. Correct? /Casper On 1 Sep., 15:47, Roel Spilker r.spil...@gmail.com wrote: Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlformore information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
I actually prefer @Cleanup to the JDK 7 proposal in that it presumably just cleans up at the end of the variable's scope ala C++. If you need ordering amongst several @Cleanup variables, then you can always introduce {...} scoping, right? If so, then I'd rather introduce such things only as needed rather than the JDK 7 proposal's approach. Roel Spilker wrote: Casper, You are correct. I just wanted the other readers to know that it is not limited to close. It is however limited to no-args methods. Roel On Sep 1, 4:10 pm, Casper Bang casper.b...@gmail.com wrote: I think you misunderstood Roel. I am aware of the method name argument override, I was merely exploring the different implementations and implications of these two ARM blocks. The JDK7 version would have to rely on a new interface Disposable being added to the libraries, as the abomination known as checked exceptions (IOException) once again gets in the way of simply using the existing Closable. Lombok couldn't care less what it's closing and could in fact be used as a C++ deconstructor. Correct? /Casper On 1 Sep., 15:47, Roel Spilker r.spil...@gmail.com wrote: Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlformore information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS X], here I am, stuck in the middle with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
True, but I don't think many are aware of this. The JDK7 proposal by Joshua Bloch specifically adds the multi-scoping aspect over the existing C# implementation, which only allows multi-scoping of the same type. Constructs that minimizes variable leakage into scope space (temporary variables) appeals somewhat to me, something Lombok can't possible address without an ElementType.TYPE_BLOCK. I assume this is also a major reason why certain well known people on the Coin mailing-list claim this should be handled in the language rather than by annotations. There's a profound fear of the misuse of annotations, though personally I consider annotation DSL burial (JPA) way more abusive than say Lombok. /Casper On 1 Sep., 19:47, Reinier Zwitserloot reini...@gmail.com wrote: Yes, you can scope to your hearts content with {} blocks. For those not aware of this: There's a rarely used feature of the java language: separate blocks. You can put { (statements) } anywhere in java code where a statement is legal. Like any other occurrence of {} to delimit code, any variable declarations inside the {} are not visible outside the brackets. So, this: public void test() { int foo = 1; { int bar = foo + 2; } //MARK } is legal, and 'bar' will not be visible at the mark. Because of this feature, @Cleanup is what it is; if you want an explicit close point, then use a block. In practice, a decent amount of resources you may want to @Cleanup require try/catch blocks, which are of course also their own scope: try { @Cleanup InputStream in = new FileInputStream(path);} catch ( IOException e ) { throw new DatabaseAccessException(e); } After all, the act of creating a resource tends to throw the same kinds of exceptions as using the resource. Funny thing, this @Cleanup thing. I never considered this style of ARM until forced into it by lombok's particular limitations (Specifically: it needs code that passes the tokenizer and tree maker before lombok can run its transformations), and then it turns out it's in many ways superior to the existing proposal. I don't think coin is going to go this route though, it's a bit late for such a drastic change. On Sep 1, 4:31 pm, Jess Holle je...@ptc.com wrote: I actually prefer @Cleanup to the JDK 7 proposal in that it presumably just cleans up at the end of the variable's scope ala C++. If you need ordering amongst several @Cleanup variables, then you can always introduce {...} scoping, right? If so, then I'd rather introduce such things only as needed rather than the JDK 7 proposal's approach. Roel Spilker wrote: Casper, You are correct. I just wanted the other readers to know that it is not limited to close. It is however limited to no-args methods. Roel On Sep 1, 4:10 pm, Casper Bang casper.b...@gmail.com wrote: I think you misunderstood Roel. I am aware of the method name argument override, I was merely exploring the different implementations and implications of these two ARM blocks. The JDK7 version would have to rely on a new interface Disposable being added to the libraries, as the abomination known as checked exceptions (IOException) once again gets in the way of simply using the existing Closable. Lombok couldn't care less what it's closing and could in fact be used as a C++ deconstructor. Correct? /Casper On 1 Sep., 15:47, Roel Spilker r.spil...@gmail.com wrote: Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new
[The Java Posse] Re: Java officially lags C
Yes, you can scope to your hearts content with {} blocks. For those not aware of this: There's a rarely used feature of the java language: separate blocks. You can put { (statements) } anywhere in java code where a statement is legal. Like any other occurrence of {} to delimit code, any variable declarations inside the {} are not visible outside the brackets. So, this: public void test() { int foo = 1; { int bar = foo + 2; } //MARK } is legal, and 'bar' will not be visible at the mark. Because of this feature, @Cleanup is what it is; if you want an explicit close point, then use a block. In practice, a decent amount of resources you may want to @Cleanup require try/catch blocks, which are of course also their own scope: try { @Cleanup InputStream in = new FileInputStream(path); } catch ( IOException e ) { throw new DatabaseAccessException(e); } After all, the act of creating a resource tends to throw the same kinds of exceptions as using the resource. Funny thing, this @Cleanup thing. I never considered this style of ARM until forced into it by lombok's particular limitations (Specifically: it needs code that passes the tokenizer and tree maker before lombok can run its transformations), and then it turns out it's in many ways superior to the existing proposal. I don't think coin is going to go this route though, it's a bit late for such a drastic change. On Sep 1, 4:31 pm, Jess Holle je...@ptc.com wrote: I actually prefer @Cleanup to the JDK 7 proposal in that it presumably just cleans up at the end of the variable's scope ala C++. If you need ordering amongst several @Cleanup variables, then you can always introduce {...} scoping, right? If so, then I'd rather introduce such things only as needed rather than the JDK 7 proposal's approach. Roel Spilker wrote: Casper, You are correct. I just wanted the other readers to know that it is not limited to close. It is however limited to no-args methods. Roel On Sep 1, 4:10 pm, Casper Bang casper.b...@gmail.com wrote: I think you misunderstood Roel. I am aware of the method name argument override, I was merely exploring the different implementations and implications of these two ARM blocks. The JDK7 version would have to rely on a new interface Disposable being added to the libraries, as the abomination known as checked exceptions (IOException) once again gets in the way of simply using the existing Closable. Lombok couldn't care less what it's closing and could in fact be used as a C++ deconstructor. Correct? /Casper On 1 Sep., 15:47, Roel Spilker r.spil...@gmail.com wrote: Caster, that is not entirely correct. The close methode (actually, close is just the default, you can specify an other method name if you want) will be called when the variable goes out of scope. Unfortunately, java does not allow an annotation on a code block. So an equivalent programm would be: { @Cleanup InputStream in = new FileInputStream(...); // Do something else... } On Sep 1, 3:10 pm, Casper Bang casper.b...@gmail.com wrote: The neat thing about this is that we do not have to wait until the Java API has been retrofitted with the Disposable interface. However, you won't get the scope limitation benefits (the in and out variable is scoped the whole method). I kind of wish we could use annotations on blocks, so this would be possible instead: @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something... } @Cleanup{ InputStream in = new FileInputStream( ... ); // Do something else... } /Casper On 1 Sep., 14:53, Roel Spilker r.spil...@gmail.com wrote: For ARM-blocks you can have a look at the @Cleanup annotation of Lombok and have ARM-blocks for Java right now! The following code will close both streams correctly after they run out of scope. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[1]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } } Seehttp://projectlombok.org/features/Cleanup.htmlformore information On Sep 1, 2:19 pm, joel.neely joel.ne...@gmail.com wrote: According to coverage athttp://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 , Snow Leopard, the latest version of Mac OS X, added blocks to C. The article illustrates this new language construct with the by-now canonical ARM and home-grown-control-structure examples. Hey, Java! Closures to the left of me [JRuby, Scala, etc.], blocks to the right [C on OS
[The Java Posse] Java - Code - URL Connection ClassGoogle Transliteration
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, 1); systemSettings.put(sun.net.client.defaultReadTimeout, 1); 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=1langpair=en|hitext=sdffdgdf sdfsd qwewq adfasw qeqewq asdfqw3ww adas adasdasd adasds tl_app=1; //http://www.google.com/transliterate/indic?tlqt=1langpair=en| hitext=sdfsd%20qwewq%20adfasw%20qeqewq%20asdfqw3ww%20adas %20adasdasdtl_app=1 String str = tlqt=1langpair=en|hitext=sdfsd%20qwewq%20adfasw %20qeqewq%20asdfqw3ww%20adas%20adasdasdtl_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(brj= + 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(brk= + k + Comma Array Val=+ strval2[k] + br); //now replace all and : characters. strval3 = strval2[k]; strval3 = strval3.replaceAll(\,); strval3 = strval3.replaceAll(:,); out.println(brk= + 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
Casper Bang wrote: True, but I don't think many are aware of this. Hmm I've used {...} liberally for scoping in Java and C++ since I first used C++. It's one reason I consider C unusable even compared to C++'s and despite C++'s sins. The JDK7 proposal by Joshua Bloch specifically adds the multi-scoping aspect over the existing C# implementation, which only allows multi-scoping of the same type. Constructs that minimizes variable leakage into scope space (temporary variables) appeals somewhat to me, something Lombok can't possible address without an ElementType.TYPE_BLOCK. I assume this is also a major reason why certain well known people on the Coin mailing-list claim this should be handled in the language rather than by annotations. There's a profound fear of the misuse of annotations, though personally I consider annotation DSL burial (JPA) way more abusive than say Lombok. Annotations whiich produce language-like effects, i.e. changes in the byte code (not just metadata) for the class in question is a slippery slope. The extreme cases would generally seem to be a bad thing -- though it is the only way we have to (relatively) cheaply get something like Lombok right now. There's a /huge /aversion to new keywords at this point and something like try InputStream in = new FileInputStream(path); just doesn't look right. Something like auto InputStream in = new FileInputStream(path); might, but it's still a new keyword. Overall, however, the point is that to eliminate the need for {...} bracketing where it is otherwise unnecessary, e.g.: auto Foo foo = new Foo(); auto Bar bar = new Bar(); auto Baz baz = new Baz(); // code using vars here ... rather than (in the one true bracing style): try ( Foo foo = new Foo() ) { try ( Bar bar = new Bar() ) { try ( Baz baz = new Baz() ) { // code using vars here ... } } } or even try ( Foo foo = new Foo() ) { try ( Bar bar = new Bar() ) { try ( Baz baz = new Baz() ) { // code using vars here ... } } } -- Jess Holle --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
for local variables, javac actually does almost nothin:it only frees that local variable slot for a future local variable theres a nice puzzle about that in the java specialists newsletter: http://www.javaspecialists.eu/archive/Issue173.html of course youre not suppose to know its about local variables and javac before seeing the puzzle... On Tue, Sep 1, 2009 at 9:44 PM, Mark Derricuttm...@talios.com wrote: I've always been intrigued by these blocks we have in java, what does javac actually generate for them? I'd always hoped that the closures proposals might just start small and make these blocks a first class citizen. From: public void test() { int foo = 1; { int bar = foo + 2; } //MARK } to: public void test() { int foo = 1; Method foobar = { int bar = foo + 2; } foobar.invoke(null); //MARK } *sigh* I want my closures and mixins. -- Pull me down under... Sent from Auckland, Auk, New Zealand On Wed, Sep 2, 2009 at 5:47 AM, Reinier Zwitserloot reini...@gmail.com wrote: You can put { (statements) } anywhere in java code where a statement is legal. Like any other occurrence of {} to delimit code, any variable declarations inside the {} are not visible outside the brackets. So, this: -- http://mapsdev.blogspot.com/ Marcelo Takeshi Fukushima --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
Don't know what happens underneath, but they appear to be parsed by the production rule Block - {Statement*} and have the Tree node associated with a com.sun.tools.javac.code.Scope hashtable that's special in that they can be nested. That would make sense I guess, going the other way, a member-wide variable is also contained in a Scope with nested Scopes (methods). That's why I think it would be possible to allow an annotation type on a block. There are more things than just ARM you could want to do. Transactions, logging, timing etc. As Stephen Colebourne has hinted at in the past, one could even use it for DSL's: @DSL(lang=jpql, variant=hibernate){ SELECT FROM foobar; } That would take care of the need of multi-line strings for most cases. /Casper On 2 Sep., 03:12, Marcelo Fukushima takesh...@gmail.com wrote: for local variables, javac actually does almost nothin:it only frees that local variable slot for a future local variable theres a nice puzzle about that in the java specialists newsletter:http://www.javaspecialists.eu/archive/Issue173.html of course youre not suppose to know its about local variables and javac before seeing the puzzle... On Tue, Sep 1, 2009 at 9:44 PM, Mark Derricuttm...@talios.com wrote: I've always been intrigued by these blocks we have in java, what does javac actually generate for them? I'd always hoped that the closures proposals might just start small and make these blocks a first class citizen. From: public void test() { int foo = 1; { int bar = foo + 2; } //MARK } to: public void test() { int foo = 1; Method foobar = { int bar = foo + 2; } foobar.invoke(null); //MARK } *sigh* I want my closures and mixins. -- Pull me down under... Sent from Auckland, Auk, New Zealand On Wed, Sep 2, 2009 at 5:47 AM, Reinier Zwitserloot reini...@gmail.com wrote: You can put { (statements) } anywhere in java code where a statement is legal. Like any other occurrence of {} to delimit code, any variable declarations inside the {} are not visible outside the brackets. So, this: --http://mapsdev.blogspot.com/ Marcelo Takeshi Fukushima --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[The Java Posse] Re: Java officially lags C
On Tue, Sep 1, 2009 at 5:44 PM, Mark Derricutt m...@talios.com wrote: I've always been intrigued by these blocks we have in java, what does javac actually generate for them? Not much. It just reuses slots. But don't take my word for it ~/test$ cat Test.java public class Test { public void test() { int foo = 1; { int bar = foo + 2; System.out.println(inner bar = + bar); } int bar = foo + 3; System.out.println(outer bar = + bar); } } ~/test$ javac Test.java ~/test$ javap -c -private Test Compiled from Test.java public class Test extends java.lang.Object{ public Test(); Code: 0:aload_0 1:invokespecial#1; //Method java/lang/Object.init:()V 4:return public void test(); Code: 0:iconst_1 1:istore_1 2:iload_1 3:iconst_2 4:iadd 5:istore_2 6:getstatic#2; //Field java/lang/System.out:Ljava/io/PrintStream; 9:new#3; //class java/lang/StringBuilder 12:dup 13:invokespecial#4; //Method java/lang/StringBuilder.init:()V 16:ldc#5; //String inner bar = 18:invokevirtual#6; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 21:iload_2 22:invokevirtual#7; //Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder; 25:invokevirtual#8; //Method java/lang/StringBuilder.toString:()Ljava/lang/String; 28:invokevirtual#9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 31:iload_1 32:iconst_3 33:iadd 34:istore_2 35:getstatic#2; //Field java/lang/System.out:Ljava/io/PrintStream; 38:new#3; //class java/lang/StringBuilder 41:dup 42:invokespecial#4; //Method java/lang/StringBuilder.init:()V 45:ldc#10; //String outer bar = 47:invokevirtual#6; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 50:iload_2 51:invokevirtual#7; //Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder; 54:invokevirtual#8; //Method java/lang/StringBuilder.toString:()Ljava/lang/String; 57:invokevirtual#9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 60:return } The instructions istore_2 and iload_2 each appear twice (the stores happen after the adds, the loads appear before the string builds). That's javac reusing the same slot in the local variable table since the inner bar is no longer needed when it encounters the outer bar. slot 1 is tied to foo for the enitre method. const 1 is 1, const 2 is 2, and const 3 is 3. I'd always hoped that the closures proposals might just start small and make these blocks a first class citizen. Closures are more complicated than simple blocks. Because closures capture variables into potentially long lived objects that transcend normal stack behavior, mutable variables need to be heap allocated. That, by the way, is why Java's existing sorta-closures (instances of anonymous inner classes) are only allowed to capture final variables. In Java 1.2 the largest users of Java were C++ programmers who were mortified at the thought of Java silently introducing extra heap allocation without explicit new. http://madbean.com/2003/mb2003-49/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---