I want to change a String so that all the uppercase characters become lowercase, and all the lower case characters become uppercase. Number characters are just ignored.
so "AbCdE123" becomes "aBcDe123"
I guess there must be a way to iterate through the String and flip each character, or perhaps some regular expression that could do it....
I need to access (read in) data repeatedly from a database in my java codes, and therefore adopted JDBC. However, it seems to me that using JDBC takes up a lot of memory. I tried to be careful about closing the objects created for JDBC (ResultSet, Statemenet), but still it seems to hog a lot of memeory especially compared to reading in i...
I'm setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root cause:
java.lang.ClassNotFoundException: java.sql.SQLClientInfoException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappC...
My current JDK on Mac OS (10.6) is set to 1.6 and I'd like to switch to 1.5.
A listing of '/System/Library/Frameworks/JavaVM.framework/Versions/' shows:
lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 5 Nov 3 18:34 1.6 -> 1.6.0
...
I have a simple problem that says:
A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string and print out a message as to whether or not the string entered would be considered a valid password.
I need help on completing this code....
I found some sample code that uses an interface named com.sun.jersey.spi.container.ContainerRequestFilter. Someone was nice enough to post the javadoc here, but it just looks like it was some university professor who also couldn't find the javadocs. I know I can build it myself, but would rather not go through the work. Is there a cen...
I'm writing a stateless EJB.
I had methods like:
public String getXxx(final String userId) throws ... {
final Query query = em.createNativeQuery(...);
query.setParameter(1, userId);
return (String)query.getSingleResult();
}
Can I cache the Query object instantiating it at load time and using it in a multi-thread environmen...
I have a method that is going to the DB so all our JDBC stuff in the DAO method is inside a try/catch block. It is catching SQLException
When I write a test case against this method and if a SqlException occurs then my testcase does not say 'caused an error'. it just goes on its merry way.
However, If I dont catch the SqlException i...
I'm essentially trying to do the following on a Java/JSP-driven web site:
User supplies a password
Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a text file as well as a number of binary files that are stored on the server. It's essentially a backup of the user's files and settings.
Lat...
I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that are stored in the collection (primarily their IDs, and not the remaining contents of each element).
Anyone have an idea of how I might go...
Is there any reason I should avoid compiling in debugging information with Javac in my Java classes for use in a production server? Are there any speed or security concerns I should be aware of?
Please note that I am referring to debugging information like line numbers in stack traces, not the debug level of loggers.
Related Questio...
Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable's value. Instead, hover behaves as if I were in normal Java perspective:
I've tried cleaning the project, re-importing it, etc., all to no avail. Anything I'm missing here?
...
Is there a way to set Java's XPath to have a default namespace prefix for expressons? For example, instead of: /html:html/html:head/html:title/text()", the query could be: /html/head/title/text()
While using the namespace prefix works, there has to be a more elegant way.
Sample code snippet of what I'm doing now:
Node node = ... // DO...
What are the advantages of using a dynamic client with JAX-WS services as opposed to just using generated client classes? What are the disadvantages?
**For my particular case I am using Apache CXF, I'm not sure what other libraries allow "dynamic" clients.
-I thought I didn't need to add this, but... I'm looking for non-obvious(I know....
My development environment (Mac OS 10.6) uses JDK 1.6 while production relies on 1.5. Upgrading the prod to 1.6 isn't an option at the moment so I followed the steps to install 1.5 on my machine. However, after I set the correct JAVA_HOME version to 1.5 with Grails 1.1, I get the error message:
2009-11-12 09:20:34,881 INFO [STDOUT] 09:...
I'd like to know if there is an easy way to get character input from a JTextField in Java as they happen, not after an enter keystroke.
In my case I want the characters (text) to be read in, and when the enter key is hit, do something with the characters already collected.
...
I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it to appear as a 4x8 grid, so I have a 2-dimensional array of JPanels...
Question is, is there any formula that can convert the array[i][j] ...
If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator.
If I have an *xml, *jsp, or pretty much anything besides a Java source file, that option doesn't appear. Is there any way to get it to appear, or any similar functionality that will let me jump immediately to th...
I'm designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There's one block of text on one of the pages which we anticipate will need to be updated occasionally (a few times a year?) by a system admin. Wh...
So i creating a little java app and am just wondering how i can get the contents of a JTextField and then assign the value into a String variable, I thought below would work:
JTextField txt_cust_Name = new JTextField();
String cust_Name;
txt_cust_Name.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ...