What's a good algorithm for counting submatrices within a larger, dense matrix? If I had a single line of data, I could use a suffix tree, but I'm not sure if generalizing a suffix tree into higher dimensions is exactly straightforward or the best approach here.
Thoughts?
My naive solution to index the first element of the dense matrix...
Hey all,
I need to remove some characters at the end of a certain list of item. These characters are always the same (C, CD, PDF, CPDF, M) and with this regular expression I'm able to get rid of them :
str.replaceAll("(C|CD|PDF|CPDF|M)$", "");
However, I'm not able to inverse this expression : I'd like to be able to isolate (by remo...
I'm trying to implement Future.get(long, TimeUnit) in terms of TimeUnit.timedWait(Object, long).
It's not clear how to use TimeUnit.timedWait(Object, long) in a way that handles spurious wakeups without losing the nanosecond component of TimeUnit. Normally you'd do something like this:
public V get(long timeout, TimeUnit unit)
{
long...
Hi.So I can easily accomplish task to find largest number and then if can be divided by three, print out. But do not know how to find second largest number from users sequence.
Thanks for any hints!
public class SecondLargest {
public static void main(String[] args) {
int max = 0;
Scanner scan = new Scanner(System.i...
I am getting the error
Exception in thread "main" java.lang.NoClassDefFoundError:
When I try and run a compiled class on Ubuntu. I am using a very simple Helloworld example, and the millions of responses which already exist on the internet suggest that my CLASSPATH and JAVA_HOME variables have been incorrectly set.
However, I hav...
Hi all,
I've got a pretty special setup: I create all the classes in Java, connect them in my application (several ManyToOne-relationships).
Then, I'd like to iterate over my objects and save them into the database. Sometimes, an object is already in the database, then it should not be persisted again.
I implemented the hashCode() and...
Hi, I'm trying to register a Servlet in Jetty 7.0 programmatically. All the examples I find are for Jetty 6, and Jetty 7 is quite different. Here is my server side:
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
public class Bootstrapper {
public static void main(String[] args) th...
I look around and it seems that zipping all the files together is the way to go. If that the case this is the design I am thinking of doing. Please let me know if there is more efficient way of doing this
Client select multiples file of downloading, then click Download
servlet receive the requests, then do multiple SELECT (files are sa...
I have to work with some legacy code written in a "push" callback style. The architecture looks like this (pseudo-Java)
public interface Callback
{
public void consumeData(Object data);
}
public class Worker // The legacy class
{
private Callback cb;
public Worker(..., Callback cb)
{
this.cb = cb;
...
...
I have a BufferedImage of type TYPE_INT_BGR. I need to do a pixel-by-pixel comparison to another BufferedImage to compute the "distance" between the two images. I have something that works, but is slow. I get a pixel from the "reference" image, break it up into RGB bytes with:
int pixel = referenceImage.getRGB(col, row);
int ...
Hi,
I have this logback.xml file:
<configuration debug="true" scan="true" scanPeriod="60 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender...
I am completely new to Java development so bear with me...
I have downloaded the Joda time library which consists of three files:
joda-time-1.6.jar
joda-time-1.6-javadoc.jar
joda-time-1.6-sources.jar
Firstly, how do I use this library in one of my own NetBeans projects?
Secondly, generally speaking, what is the distinction be...
We're using :
JBoss 5
Flex SDK 3.5
BlazeDS 3, with integrated authentication (through JAAS and JBossSX)
Failed login are always indicated to the flex client by the same fault code : Client.Authentication
However, the underlying JAAS LoginModule throws a specific javax.security.auth.login.LoginException subclass.
How can we propagat...
Hello everyone. First, im new to developing for android and this forum. my question is this: i was looking at the "Hello world view: gridview" example and was wondering, how do i load all my images dynamically. for example in the ImageAdapter.java file, at the end there is:
private Integer[] mThumbIds = {
R.drawable.sample_2...
I'm working on a JavaScript collator/compositor implemented in Java. It works, but there has to be a better way to implement it and I think a Lexer may be the way forward, but I'm a little fuzzy.
I've developed a meta syntax for the compositor which is a subset of the JavaScript language. As far as a typical JavaScript interpreter is c...
I'm porting a rails app to grails that uses oauth to push messages to Twitter. Any suggestions for groovy or java examples or opinions on the various libraries mentioned on the twitter site for java?
...
Lets say we have this JPA-annotated class, with a property of type List. This code is currently working fine.
@Entity
public class Family {
...
@CollectionOfElements(targetElement=java.lang.String.class)
@JoinTable(name = "elements_family",
joinColumns = @JoinColumn(name = "idFamily")
)
@Column(name = "elemen...
I want to create a collection of objects that implement a given interface (in C# it would be something like Collection<IMyInterface>). I don't care about sorting or indexed access but would like to easily iterate over the collection with foreach (or the Java equivalent). It also needs to have as small a memory footprint as possible (and ...
Is there some way to get a value from the last inserted row?
I am inserting a row where the PK will automatically increase due to sequence created, and I would like to get this sequence number. Only the PK is guaranteed to be unique in the table.
I am using Java with a JDBC and Oracle.
I forgot to add that I would like to retrieve thi...
I've tried this for a couple of hours and wasn't able to do this correctly; so I figured I'd post it here. Here's my problem.
Given a string in java :
"this is <a href='something'>one \nlink</a> some text <a href='fubar'>two \nlink</a> extra text"
Now i want to strip out the link tag from this string using regular expressions - so th...