java

Ant task for modern multithreaded archivators (7zip, winrar etc.)

We are using Ant Zip task, which is a bit of moral obsolete (low processing speed for big files). Can anyone point me out to mature ant task ready for production using that supports multithreaded for compression/decompression? First of all I wish to increase speed of processing archive files. I found 7ZIP Ant task, but it looks a bit ...

What is the preferred method for handling unexpected enum values?

Suppose we have a method that accepts a value of an enumeration. After this method checks that the value is valid, it switches over the possible values. So the question is, what is the preferred method of handling unexpected values after the value range has been validated? For example: enum Mood { Happy, Sad } public void PrintMood(Mo...

how does one go about copying one xml document's node to another?

I'm trying to insert an element node (that has some children) from one XML into another in java. What I'm trying (which isn't working) looks like this... Node foo = document1.getChildNodes().item(3).cloneNode(true); document2.getChildNodes().item(2).appendChild(foo); I'm getting an exception that complains that i'm trying to use a n...

How do I prevent Hibernate from trimming strings?

I'm using Oracle 10g and Hibernate 2.1 (old version, but not allowed to upgrade to fix). I've got a table with a not nullable column named TIN, varchar2(9). This column is used to stage data loaded from flat files and so can store any string of length 9, including 9 spaces (that is: ' ') if the input file had 9 spaces. What ...

Java Applet Permissions

I've put together a basic applet where the user selects a file from their hard drive, it reads the first line of this file and passes that off to JavaScript for some additional preprocessing, and then when you click a button it tries to upload that file through an HTTP POST request. I found a very basic open source applet for uploading f...

Java DomImplementationLS.

I'm looking to create XML Document objects in Java and serialize them to a byte array (prior to sending them across a TCP connection). I currently have code that looks like this: public byte [] EncapsulateThingy( ThingyType thingy ) { parser.reset(); // parser is a pre-existing DocumentBuilder object Document doc = parser.newDo...

Is it possible to create a Calendar object like Tue Mar 03 13:43:00 (without time zone)?

I have a requirement of sending the calendar object with time zone, like Tue Mar 03 13:43:00. I know that Calendar object always return with Tue Mar 03 13:43:00 CST 2009, so how can I create it without the time zone? ...

What is the difference between i+=d and i=i+d in Java?

Duplicate: java += question Why aren’t op-assign operators type safe in java? When i is an integer and d is a double, i+=d works but i= i+d does not. Why is this? ...

Why can't java find my method?

Hey everyone, I am trying to wrap my mind around something in java. When I pass an object to another class' method, can I not just call any methods inherent to that object class? What is the reason code such as the example below does not compile? Thank you, class a { public static void myMethod(Object myObj) { myObj.testing();...

Best Practice Updating DB Records

Say you retrieve 100 records, and display them on a page. The user only updates 2 of the records on the page. Now you want to update only the two records, and not the other 98. Is it best to have one submit on the page, then somehow know which 2 are updated, then send only those two to the db for an update? What does the "somehow" look ...

How to reference an external library in an Ant build and general Ant help?

Hi, We have an ant build script for a project we're developing for a PDA. In eclipse we have a load of referenced libraries and I know how to get them to work when we run the jar on the PDA because we have a .lnk file where you can add the external libraries simply by adding the following: 512#"\J9\PPRO11\bin\j9.exe" -jcl:ppro11 -cp "...

How can I suppress warnings (codebase-wide) during javadoc compilation?

I'm stuck with a legacy Java codebase that has THOUSANDS of warnings when you compile it. I would love to actually fix the source of all these warnings, but unfortunately that's not an option at this time at my company (other things like "making new products that generate revenue" are considered higher priority by the people in charge; f...

What's the best way to get rid of nested ifs in code while checking for conditions?

I'm developing a BlackBerry app in Java and I have an Options class where all user settings are stored. The problem is I need to check some conditions in order to know how to react. As I keep adding more features, more GUI options are shown to the user, more settings are stored in the Options class and more conditions need to be checked ...

How to create a tiled map in Java?

So I have a tile image tile.png and I'm trying to create a tiled map all across the window. I'm building this as an applet. This is what my paint method looks like, but its not effective. When I run the applet it takes about 2 seconds and the entire screen is painted from left to right with the image, rather than everything rendered at o...

Rotate a Swing JLabel

I am currently trying to implement a Swing component, inheriting from JLabel which should simply represent a label that can be oriented vertically. Beginning with this: public class RotatedLabel extends JLabel { public enum Direction { HORIZONTAL, VERTICAL_UP, VERTICAL_DOWN } private Direction direction; I thought...

Wildcards and generics error

The code below is throwaway, a failed idea to get an Enumeration to work in the new foreach loop, however I'd like to get it compiling since I keep running into an issue with generics and wild cards. For whatever reason I cannot see how to fix it. So, what changes need to be made to make this compile? import java.util.Enumeration; i...

Consuming .NET webservice in Java (metro) - XMLNode/XMLDocument consumption?

I am a bit rusty in my Java, and this is my first time using metro/JAX-WS, so if this is a dumb question I apologize. I have to write a client that consumes a .NET webservice. I've got the basics down; I have generated the wrappers from the WSDL, and I can create my object and port and make a call and get a response. Widgets d = new ...

Determining binary/text file type?

Namely, how would you tell an archive (jar/rar/etc.) file from a textual (xml/txt, encoding-independent) one? ...

How do I fix this Java generics wildcard error?

In this question, TofuBeer was having problems creating a genericized IterableEnumeration. The answer came from jcrossley3 pointing to this link http://www.javaspecialists.eu/archive/Issue107.html which pretty much solved the problem. There is still one thing I don't get. The real problem, as effectively pointed out by erickson, was ...

java newline character insertion

how can i insert a newline character in a java applet program if i am using "label" instead of sys.out.println?? thanks in advance ...