Skip to content

Tag: java

How to set eclipse console locale/language

When developing web application with Eclipse (Helios) the tomcat output is being sent to the console. Ok, but the messages are being translated to my OS language. In fact, my Eclipse is in English, but the Tomcat output (logging) is being translated to Portuguese. Probably it’s a Tomcat configuration is…

How to filter string for unwanted characters using regex?

Basically , I am wondering if there is a handy class or method to filter a String for unwanted characters. The output of the method should be the ‘cleaned’ String. Ie: Expecting result would be: A better example: I expect the result to be: Because, i let the cleaner know that ‘ ‘, &#82…

How to start a transaction in JDBC?

Connection.setTransactionIsolation(int) warns: Note: If this method is called during a transaction, the result is implementation-defined. This bring up the question: how do you begin a transaction in JDBC? It’s clear how to end a transaction, but not how to begin it. If a Connection starts inside in a t…

Moving items around in an ArrayList

I’ve been playing around with ArrayLists. What I’m trying to achieve is a method to do something like this: I’m trying to be able to move items up in the list, unless it is already at the top in which case it will stay the same. For example, if item 3 was moved the list would be: From my sma…

Removing all whitespace characters except for ” “

I consider myself pretty good with Regular Expressions, but this one is appearing to be surprisingly tricky: I want to trim all whitespace, except the space character: ‘ ‘. In Java, the RegEx I have tried is: [s-[ ]], but this one also strips out ‘ ‘. UPDATE: Here is the particular str…

Get the indices of an array after sorting?

Suppose the user enter an array, for example: which I did know the length of it the index array would be: Now, after sorting it using Arrays.sort(Array); newArray will be like: and the newIndex will be: The problem is: how can I find the newIndex from the input Array? Answer Don’t sort the array to star…