java

Java Hashtable problem

Hi All, I am having some problem with java hashtable. Following is my hastable key and values {corpus\2.txt=[cat sparrow], corpus\4.txt=[elephant sparrow], corpus\1.txt=[elephant cow], corpus\3.txt=[cow cat]} So if i want to access first tuple i have to pass key "corpus\2.txt" to get its value. If i pass value i can get it's key. But ...

Are there any functions for truncating a double in java?

Hello Is there a Java Library function which can be used to truncate a number to an arbitrary number of decimal places? For Example. SomeLibrary.truncate(1.575, 2) = 1.57 Thanks ...

Why should I use the Sun JDK over the OpenJDK, or vice-versa?

I recently purchased a new laptop and made my old one into a Linux box, running Ubuntu. I started to download the tools that I need, and I'm getting my Java development environment set up now. I have a choice between the Sun Java 6 JDK and the OpenJDK. What advantages does one have over the other? Can I run both side by side? ...

Textbox height in a small browser window

Hi folks, I have here a peculiar problem. We have a RAP application intended for use on a PDA/phone, but when it is displayed in a small browser window, all the textboxes on the form(s) are too tall (around twice the height they should be). I've stepped through the code (The form is using GridLayout, number of columns=1, make columns e...

What is the most memory-efficient way to emit XML from a JAXP SAX ContentHandler?

I have a situation similar to an earlier question about emitting XML. I am analyzing data in a SAX ContentHandler while serializing it to a stream. I am suspicious that the solution in the linked question -- though it is exactly what I am looking for in terms of the API -- is not memory-efficient, since it involves an identity transform ...

Use a Java hash map even when there is no "mapping"?

I want to store some objects and then be able to retrieve them later as efficiently as possible. I will also remove some of them under certain conditions. It seems a hash map would be the right choice. But, from what I've seen, hash maps always associate a value with another? For example, "john" and "555-5555", his phone number. Now, m...

File names with Japanese characters turn to garbage when written to a zip file using java.util.zip.*

I have a directory with a name that contains Japanese characters, and I need to use the zip utils in java.util.zip to write it to a zip file. Writing the zip file succeeds, but when I open the resulting zip file with either Windows' built-in compressed file utility or 7-Zip, the directory with Japanese characters in the name appears as ...

Android voice call logging

I'd like to have some code be notified of any incoming and outgoing voice calls. I need to grab all the following: If it was an incoming or outgoing call Number dialed, or incoming caller-id phone number Duration of call, or if it was a missed call It would also be really slick if I could get more contact info, specifically the cont...

Full Text Search like Google

I would like to implement full-text-search in my off-line (android) application to search the user generated list of notes. I would like it to behave just like Google (since most people are already used to querying to Google) My initial requirements are: Fast: like Google or as fast as possible, having 100000 documents with 200 hundr...

JAVAX-XML-WS Handler

I got this example code from a website, can I get the parameter input value and response return value from handleMessage also? in this example i can only get the method name. (Method being called) public boolean handleMessage(SOAPMessageContext context) { // get the SOAPMessageContext SOAPMessageContext sctx = (SOAPMessageConte...

Server-Side Redirect in PHP

I have a Java application that I need to integrate our existing PHP website with. The vendor wants us to do a server-side redirect to allow for secure authentication and single-sign-on, but I'm not sure how to do that in PHP. The vendor explained the workflow as follows: User clicks on a 'Open Application' link on our PHP site The PHP ...

MulticastSocket: Socket operation on non socket.

I have some code like this: InetAddress bind = InetAddress.getByName("192.168.0.1") MulticastSocket socket = new MulticastSocket(new InetSocketAddress(bind,0)); socket.setInterface(bind); On windows 7 and windows XP with JDK6u17,I got a SocketException: Socket operation on non socket. But if I change the line 2 to : MulticastSocket ...

What will netbeans IDE do when I press Ctrl+F6 to run a java file?

I have no idea of how Netbeans IDE run a java file. Firstly, it would ensure the .class file is up-to-date. Then, execute the class. But from where (working directory) and with which command (parameter)? I observe difference on how relative path is located when I run the java file from Netbeans IDE and when I run using Windows command...

Maven - lookup dependencies at runtime

Hi all, I would like to be able to determine what versions I am running of a dependency at runtime as well as the version of the web application itself. Each web application I deploy is packaged with a pom.xml which I can read from, that part is trivial. The next part is parsing the pom without much effort. As the web application i...

BindException: address already in use on a client socket?

I've got a client-server tiered architecture with the client making RPC-like requests to the server. I'm using Tomcat to host the servlets, and the Apache HttpClient to make requests to it. My code goes something like this: private static final HttpConnectionManager CONN_MGR = new MultiThreadedHttpConnectionManager(); final Ge...

Spring ROO like Console Application

I am looking to build a console driven application, which would somewhat like look like the Spring ROO Console, any ideas ?. ...

Jython Optimizations

Are their any ways to optimize Jython without resorting to profiling or significantly changing the code? Specifically are there any flags that can be passed to the compiler, or code hints in tight loops. ...

Understanding Generics

@Entity @Table(name = "your_entity") public class YourEntityClass implements IEntity<Long> { @Id @SequenceGenerator(name = "gen_test_entity2_id", sequenceName = "test_entity2_id_seq", allocationSize = 10) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_test_entity2_id") pr...

SoundTouch on Android?

Hey, I am trying to change the pitch of an audio file in an android application. I have found an open source library online "SoundTouch" (http://www.surina.net/soundtouch), do you think I can use this library in an android app? I have been Googling "SoundTouch in Java" an have found this data (http://www.aplu.ch/classdoc/jaw/ch/aplu/j...

Custom ArrayAdapter not Working?

This is one of those cases where I had the code working, tried to add something else, and then found that my previous code has stopped working. It crashes when the program starts. The error seems to lie with the definition of the ArrayAdapter custom class, as if I try using a built in adapter, it works fine. Any help? public class MainE...