I want to take two times (in seconds since epoch) and show the difference between the two in formats like:
2 minutes
1 hour, 15 minutes
3 hours, 9 minutes
1 minute ago
1 hour, 2 minutes ago
How can I accomplish this??
...
There's a name for this, but I don't know what it is so it's hard to google.
What I'm looking for is something in the java concurrency utilities, which is a pair of queues, an "pending" queue used by a producer, and a "processing" queue used by a consumer, where the consumer can swap the queues atomically. If used in this way (1 produce...
Okay, I'm trying to load a file in Java using this code:
String file = "map.mp";
URL url = this.getClass().getResource(file);
System.out.println("url = " + url);
FileInputStream x = new FileInputStream("" + url);
and despite the file being in the same folder as the class it says it can't find it (yes, it is in a try catch block in the...
I have Enterprise Application with EJB3 and JSF on Glassfish server. After running this application for more than 2 weeks I realized that I have problem with Class Loading. I don't think this is a problem with permgen. The classes loaded every time when I open a page but then they never erased from the memory. Here is the snapshot of or ...
I need to create an empty map if the map its null.
if (fileParameters == null)
fileParameters = (HashMap<String, String>) Collections.EMPTY_MAP;
The problem is that I get a code warning:
Type safety: Unchecked cast from Map to HashMap
what its the best way to create this emptyMap.
...
I need to interface an existing application with Acegi/Spring security.
In order to get started I am looking for one simple piece of information: in this context, will HttpServletRequest.getUserPrincipal() called from my application properly return the username obtained through Spring (as opposed to using Spring-specific objects)? I hav...
How can I find out what caused equals() to return false?
I'm not asking about a sure-way, always right approach, but of something to aid in the development process. Currently I have to step into the equals() calls (usually a tree of them) until one of them is false, then step into it, ad nauseam.
I thought about using the object graph,...
Can a Java application be loaded in a separate process using its name, as opposed to its location, in a platform independent manner?
I know you can execute a program via ...
Process process = Runtime.getRuntime().exec( COMMAND );
... the main issue of this method is that such calls are then platform specific.
Ideally, I'd wrap a m...
Is it possible to have objects stored in a data structure for the duration of an App Server's uptime? Basically I want an EJB that interfaces with this Data Structure, but does not require a full fledged database solution.
As an example I made this dummy animal object:
package com.test.entities;
public class Animal implements java.io...
Anyone know the reason (just curious)
...
I'd like to compute power spectral density of time series; do some bandpass, lowpass, and highpass filtering; maybe some other basic stuff.
Is there a nice open-source Java library to do this?
I've hunted a bit without success (e.g., Googling "power spectral density java" or "signal processing java" and clicking through links, looking ...
I have a Map with my data and want to build a query string with it, just like I would with http_build_query on PHP. I'm not sure if this code is the best implementation of it or if I'm forgetting something?
public String toQueryString(Map<?, ?> data) throws UnsupportedEncodingException {
StringBuffer queryString = new StringBuffer()...
I need a method to be called in an App Server (Glassfish) every 5 seconds, no matter what. Are timers reliable enough for this? What are my options.
...
I'm trying to figure out why this particular snippet of code isn't working for me. I've got an applet which is supposed to read a .pdf and display it with a pdf-renderer library, but for some reason when I read in the .pdf files which sit on my server, they end up as being corrupt. I've tested it by writing the files back out again.
I'...
I am trying to port code from using java timers to using scheduledexecutorservice
I have the following use case
class A {
public boolean execute() {
try {
Timer t = new Timer();
t.schedule (new ATimerTask(), period, delay);
} catch (Exception e) {
return false;
...
I'm not sure if this is the best way to ask this question but I'm in the very early stages of learning programming/development and there are a lot of things that I would like to do including web development and at some point when I have some proficiency, mobile development.
I started out thinking I would learn Java because of its over...
Hi guys,
I have a requirement that a Map will be constructed with up to 50~200 entries (it could be more, let's call it not-too-little anyway). The writing is only done once and the reading (using Map.get("keyName")) can go more than 20 per request (it's a webapp).
I'm going for Hashmap currently as it (I suppose) gives me the most opt...
how i embed a running windows program into java applet, like notepad, mspaint,...
...
Hi...!
I downloaded the Apache HWPF. I want to use it to read a doc file and write its text into a plain text file. I don't know the HWPF so well.
My very simple program is here:
I have 3 problems now:
Some of packages have errors (they can't find apache hdf). How I can fix them?
How I can use the methods of HWDF to find and extract...
The applet is in a signed JAR. Last line in console reads:
security: Checking if certificate is in Deployment permanent certificate store
CPU and memory usage are normal. Other page elements still respond. It's just that the applet is not displayed.
There is another applet in the same page but it works.
Any ideas?
Thread dump fo...