java

What order should I use GzipOutputStream and BufferedOutputStream

Can anyone recommend whether I should do something like: os = new GzipOutputStream(new BufferedOutputStream(...)); or os = new BufferedOutputStream(new GzipOutputStream(...)); Which is more efficient? Should I use BufferedOutputStream at all? ...

Java Library for PDF Rendering

Does anyone know a good library for PDF rendering for Java? Ideally, it should support not only displaying the image but also retrieving the text from it, finding which text is at a certain location, etc. ...

Problem outputting unicode in Java

I'm trying to write unicode characters (♠) using System.out, and a question mark gets printed instead. I'm using IntelliJ on Windows, and trying to print within the IDE. ...

Format date in hql query

hi all, i want to format date to string in hql select, for example i have purchasing data with transaction date in it: class Purchase { private Date datePurchase } and i want to select date in a certain format, for example yyyyMMdd, can i do that in hql? actually i can iterate through all purchase data returned by query, and star...

Android AlarmManager

Can someone please show me some sample code on how to use an AlarmManager in android. I have been playing around with some code for a few days and it just won't work... I need to trigger a block of code after 20 minutes from the AlarmManager being set. Thanks. ...

Question about Java polymorphism and casting

I have a class C. Class E extends it. E e = new E(); C c = new C(); Why is e = (E) c; Upon further review: though numeric conversions have the same syntax as casting objects, some confusion arose. At any event, the above does not give a compilation, but rather a runtime error - so a class can be casted to subclass in some instances...

Passing data types from C++ to Java/Java to C++

What data types can be passed between c++ and java/java to c++? Also, are the data types equivalent in terms of size? ...

Best Java 7 features

Possible Duplicate: What new features in java 7 do you find most useful? What are some features that you like in the next version of Java? ...

How to build jars from IntelliJ properly?

I have a project that contains a single module, and some dependencies. I'd like to create a jar, in a separate directory, that contains the compiled module. In addition, I'd like to have the dependencies present beside my module. No matter how I twist IntelliJ's "build jar" process, the output of my module appears empty (besides a META-...

Undecorate JInternalFrame on MacOS

I am trying to undecorate a JInternalFrame, i.e. remove the default titlebar using the following code; BasicInternalFrameUI ui = (BasicInternalFrameUI)internalFrame.getUI(); ui.getNorthPane().setPrefrredSize(new Dimension(0,0)); I works on windows but the second line throws a NullPointerException on MacOS Any ideas why and how to get...

Java: Code Examples for Tutoring

Are there any tips you have for preparing useful example code ? ...

Can I find the URL for a spring mvc controller in the view layer?

I think what I need is called reverse url resolution in Django. Lets say I have an AddUserController that goes something like this: @Controller @RequestMapping("/create-user") public class AddUserController{ ... } What I want is some way to dynamically find the url to this controller or form a url with parameters to it from the view (...

Java Reflection: Create an implementing class

Class someInterface = Class.fromName("some.package.SomeInterface"); How do I now create a new class that implements someInterface? I need to create a new class, and pass it to a function that needs a SomeInterface as an argument. ...

indent XML text with Transformer

I'm writing an XML file with the following code: Source source = new DOMSource(rootElement); Result result = new StreamResult(xmlFile); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.transform(source, result); and this is the output file...

Auto scale and rotate images

Given: two images of the same subject matter; the images have the same resolution, colour depth, and file format; the images differ in size and rotation; and two lists of (x, y) co-ordinates that correlate the images. I would like to know: How do you transform the larger image so that it visually aligns to the second image? (Option...

shlex alternative for Java

Is there a shlex alternative for Java? I'd like to be able to split quote delimited strings like the shell would process them. For example, if I'd send : one two "three four" and perform a split, I'd like to receive the tokens onetwothree four ...

JSR223: Calling Java "varargs" methods from script

Hello, I have a method that looks like this on Java: public void myMethod(Object... parms); But I can't call this method as expected from the scripts. If, in ruby, I do: $myObject.myMethod(42); It gives me org.jruby.exceptions.RaiseException: could not coerce Fixnum to class [Ljava.lang.Object If I try the following in Javascrip...

What are the Java equivalents to Linq and Entity Framework

Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are? ...

Non-Windows RAD Web development

I have spent most of my web-development career in the Microsoft camp, but for different reasons I am trying to look at options. Some years back I did a bit of Java/Struts development in eclipse, which was nice for its time but my memories of it are not close to what Visual Studio delivers today. Some of the strengths of the MS stack a...

Do you always REDIRECT after POST? If yes, How do you manage it?

Say, you are submitting a form, which affects your database (adding records/ deleting them/ updating them) and this is how your request looks like: POST /application/action=update Now, say, you are done with your update, so you would like to take the user to the home page. Response.sendRedirect /application/action=home This works w...