Skip to content

Tag: java

How to change Jasper report Print name

When I send the jasper report to print, the printer shows the document name as “jasper report-report name” (When there is a printing que, document name is also “jasper report” ). How can I change it to another name? Answer Using JasperReports API If you are using JasperReports API you …

Which is fast URLConnection or Socket

For getting data from remote url which connection type will work fast URLConnection or Socket. Answer Both have different purposes, depending upon your need A socket can implement almost a duplex kind of functionality, whereas a url connection can connect to a given URI and read its content.

What’s the console.log() of java?

I’m working on building an Android app and I’m wondering what the best approach is to debugging like that of console.log in javascript Answer The Log class: API for sending log output. Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods. The order in terms of verbosity, from lea…

Are static setter/getters allowed?

I am develoing a Web Application, in that there is a utility method named getData() which I made it as a static. Until now its fine, but this static method named getData() needs some data from setters and getters. So now my question is can we make setter/getters as static? Answer If your properties are static…

How to convert enum value to int?

I have a function which return a type int. However, I only have a value of the TAX enumeration. How can I cast the TAX enumeration value to an int? Answer You’d need to make the enum expose value somehow, e.g. (I’ve changed the names to be a bit more conventional and readable, btw.) This is assumi…

Split using a bracket

How can I split a string using [ as the delimiter? if I do I get an error Exception in thread “main” java.util.regex.PatternSyntaxException: Unclosed character class near index 1 [ Any help? Answer The [ is a reserved char in regex, you need to escape it,