I have:
public enum MyEnum{
One, Two, Three
}
From controller, I put in the model:
HashMap<MyEnum, Long> map = new HashMap<MyEnum, Long>();
map.put(MyEnum.One, 1L);
mav.addObject( "map", map);
How do I in my JSTL access the object in the map for key enum MyEnum.One, in a neat way?
${map['One']} //does not seem to work...
nor ...
If I have a resource on a classpath, I can both load it as stream fine, and there is even a URL representation of it. Unfortunately some implementations of the Url do not implement lastModified correctly.
What I would like is to take a path to something in the classpath, and then resolve it to a file that it is in on disk - if it in a j...
Say I allow the user to edit something, like the phone number in an Address Book (actually, that's exactly what I'm doing). Is there something that I can add to println that will allow me to insert a variable to display as fully editable text? The assignment that I'm doing this for doesn't actually call for this, but I think it would be ...
//Neel Patel
//Friday October 9th, 2009
/*This is a quiz program that will ask the user 10 questions. the user will answer
* these questions and will be scored out of 10.*/
class Quiz
{
public static void main (String args[])
{
//Instructions
System.out.println("instructions");
System.out.println(" ");
System.out.println("1. You...
Hi,
I'd like to port a generic text processing tool, Texy!, from PHP to Java.
This tool does ungreedy matching everywhere, using preg_match_all("/.../U").
So I am looking for a library, which has some UNGREEDY flag.
I know I could use the .*? syntax, but there are really many regular expressions I would have to overwrite, and check th...
this is the code that i am working on...
i would like to know how to reset the interactions window after every question is asked so that the window is clear for the next question to be shown to the user but i do not want the Score to be reset either so that i can display the score at the end. iam looking for the correct syntax and code ...
Consider the following example.
String str = new String();
str = "Hello";
System.out.println(str); //Prints Hello
str = "Help!";
System.out.println(str); //Prints Help!
Now, in Java, String objects are immutable. Then how come the object 'str' can be assigned value "Help!". Isn't this contradicting the immutability of strings in ...
Often I am stuck with a java class file with no source and I am trying to understand the problem I have at hand.
Note a decompiler is useful but not sufficient in all situation...
I have two question
What tools are available to view java byte code (preferably available from the linux command line )
What are good references to get fam...
I'm busy trying to port Java code that looks like this
Cipher rsa = Cipher.getInstance("RSA/ECB/nopadding");
rsa.init(Cipher.DECRYPT_MODE, RSAPrivateKey);
decryptedData = rsa.doFinal(data, 0, 128);
to C#, but as it seems the RSACryptoServiceProvider, forces you to either use OEAP or PKCS1 padding. I know no padding isn't s...
I have an expensive computation, the result of which I'd like to cache. Is there some way to make a map with two keys? I'm thinking of something like Map<(Thing1, Thing2), Integer>.
Then I could check:
if (! cache.contains(thing1, thing2)) {
return computeResult();
}
else {
return cache.getValue(thing1, thing2);
}
pseudocode. But...
I've just stumbled on a weird scenario and am wondering if anyone can explain this behaviour.
Case 1:
File base = new File("");
System.out.println(base.getAbsolutePath());
System.out.println(base.isDirectory());
System.out.println(base.canRead());
Result:
C:\workspace-sss\Commons
false
false
Case 2:
File base = new File("C:/works...
Does anyone have any experience on getting Hibernate working with ZK?
Thanks
Edit: Sorry to clarify what I am looking for:
I am looking for anyone that has experience doing this, maybe they can clarify is it easy? I have never used Hibernate before. In addition can anyone provide any resources focussed around this issue?
...
I have an unsorted linked list. To sort it, I thought I'd put the values into a TreeSet with a comparator supplied, then return those values as a new linked list. Yet, it fails.
Comparator:
public class SortSpeciesByCommonName implements Comparator<Species> {
/**
* a negative integer, zero, or a positive integer as the first ...
I have a layout that looks like this (some attributes removed for brevity)
<RelativeLayout>
<ImageButton
android:id="@+id/button"
android:nextFocusRight="@+id/gridview"/>
<GridView
android:id="@+id/gridview" />
</RelativeLayout>
When I navigate using the DPAD from the button to the gridview, the On...
Is there any way in Java to guess the date format when it is not explicitly defined?
For example a user types in 11Mar09 or 11-09-2009 or 11/09/2009 or 11-09 what is the best way of parsing this to a Date object without either a bunch of try catch or raising an error?
...
Is there a Java equivalent of the C / C++ function called frexp? If you aren't familiar, frexp is defined by Wikipedia to "break floating-point number down into mantissa and exponent."
I am looking for an implementation with both speed and accuracy but I would rather have the accuracy if I could only choose one.
This is the code sampl...
What is the cost of using Arrays.asList to convert static object arrays? Assuming that the object array has N items is it just an O(N) algorithm, where all of the items are copied by reference or is it merely a facade where the original array is put behind a List facade?
...
I want to validate a value against values retrieved from a result set's first column. I have to do the same validation operation approximately 1000 times. So, I want to decrease the time complexity of this comparison from O(n) to constant. Is there some function through which I can put all of the values of result set's column into a ...
My setup:
Netbeans 6.7
Java6
JUnit 4.5 added as the Test libraries
When I try to pass in two class arrays (cast as Object[]) I get the error "cannot find symbol" and my test case will not compile.
I do not have an issue with the other assert statements, and as I said I am using the JUnit 4.5 libraries.
Does anyone have a clu...
I have a textfield above subreport in detail section, the textfield doesn't stretch if data overflow due to the subreport, If i remove the subreport it works as expected. What should i do to stretch the textfield.
this is my detail section:-
...