Skip to content

What are Reified Generics? How do they solve Type Erasure problems and why can’t they be added without major changes?

I’ve read Neal Gafter’s blog on the subject and am still unclear on a number of points. Why is it not possible to create implementations of the Collections API that preserve type information given the current state of Java, the JVM and existing collections API? Couldn’t these replace the existing implementations in a future version of Java in a way

Regex for tree structures?

Are there regular expression equivalents for searching and modifying tree structures? Concise mini-languages (like perl regex) are what I am looking for. Here is an example that might clarify what I …

What is the Java equivalent of C’s printf %g format specifier?

I tried using Formatter.format, but that seems to leave the mantissa on numbers with 0 mantissa, whereas the C version does not. Is there an equivalent of C’s %g format specifier in Java, and if not, is there a way to fake it? My intention is to preserve the mantissa exactly like C’s for compatibility reasons. foo.c Console: Similarly,

How do I copy an object in Java?

Consider the code below: DummyBean dum = new DummyBean(); dum.setDummy(“foo”); System.out.println(dum.getDummy()); // prints ‘foo’ DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // …

Command line progress bar in Java

I have a Java program running in command line mode. I would like to display a progress bar, showing the percentage of job done. The same kind of progress bar you would see using wget under unix. Is …

How to read an external properties file in Maven

Does anyone know how to read a file in Maven. I know there are ways to use resource filtering to read a properties file and set values from that, but I want a way in my pom.xml like: <…

java.util.Date to XMLGregorianCalendar

Isn’t there a convenient way of getting from a java.util.Date to a XMLGregorianCalendar? Answer I should like to take a step back and a modern look at this 10 years old question. The classes mentioned, Date and XMLGregorianCalendar, are old now. I challenge the use of them and offer alternatives. Date was always poorly designed and is more than 20