I'm trying to create a regular expression to extract URLs from text documents using Java, but thus far I've been unsuccessful. The two cases I'm looking to capture are listed below:
URLs that start with http://
URLs that start with www. (Missing the protocol from the front)
along with the query string parameters.
Thanks! I wish I rea...
I have a method that is producing side effects, even though certain variables are marked final. Why is this? Perhaps I am confused about what final does.
@Test
public void testSubGraph() {
WeightedGraph<String, DefaultWeightedEdge> g = generateSimpleCaseGraph();
Graph<String, DefaultWeightedEdge> sub = ChooseRoot.subgraphInDirection(...
I have an XML schema:
<xsd:element name="Person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="lat" type="xsd:double" minOccurs="0"/>
<xsd:element name="lon" type="xsd:double" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
And I have an XML message:...
I have a listener inside Class A, and I want to pass Class A to my Class B inside the listener. Normally I'd just use this, but then I'd get the event that triggered the listener.
...
I was using Cobra until now because of how easy it was but unfortunately it had some problem with a few test cases. Does anyone suggest a tried-and-tested library?
I've tried Cobra's built in one and HTMLCleaner without any luck.
...
I have this problem where I have to "audit" a percent of my transtactions.
If percent is 100 I have to audit them all, if is 0 I have to skip them all and if 50% I have to review the half etc.
The problem ( or the opportunity ) is that I have to perform the check at runtime.
What I tried was:
audit = 100/percent
So if percent is...
I can't figure out what's going wrong here. This test fails:
@Test
public void testSimpleCase() {
assertTrue(JGraphtUtilities.graphEquality(ChooseRootTest.generateSimpleCaseGraph(), ChooseRootTest.generateSimpleCaseGraph()));
}
public static <V, E> boolean graphEquality(Graph<V, E> g0, Graph<V, E> g1) {
boolean result = ...
Is there an analogous form of the following code:
if(month == 4,6,9,11)
{
do something;
}
Or must it be:
if(month == 4 || month == 6 etc...)
{
do something;
}
I am trying to write an if statement that checks if this month has more than 31 days.
EDIT
I guess the real problem is I undersand some of what I am taught but every ti...
Hi, I'm trying to implement a sitemesh decorator in my site. The example on their site has a full URI linking to their site for the taglib part of the decorator file:
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
Does this mean that my site is reliant on being able to access that site? Because i...
Hi. I've been working with Seam recently and temporary conversations still confuse me.
In our project we're using ExternalContext.redirect() to redirect the user to the response page. From what I've read, a Seam conversation ends when the render response phase is called.
But then I read somewhere else that: Seam transparently propagate...
I know that I am missing something simple here. I have got this homework all done except for moving through my ArrayList. This is a undo feature of a calculator that I need to pull and remove a object from an ArrayList. Here is the method:
public void actionPerformed(ActionEvent e)
{
Status state;
state = new Sta...
I have 2 nested threads.
First thread starts multiple instances of second thread. Each second thread has to sleep for some time (5 seconds).
I want to start the first thread and return a message to user immediately, but it seems my first thread waits until all the children of second thread to finish.
How can I achieve this? Any help?
...
I am just starting with log4j. I don't have a problem with it reading my properties file and actually logging events, but it seems to be appending everything to the end of the same line. My properties file looks like this:
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A2 is set to be a Consol...
I am starting a new open source project to develop an application that will provide services to convert various documents into other formats (E.g. doc -> html, pdf -> html, plain text -> html, etc). It will utilize many other open source tools to facilitate the document conversion.
I am looking for a framework that I can use for this p...
Hi,
What effect will Java RMI have on the following line of code?
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Its not working for me in an RMI call. I am new to java and RMI so please elaborate your answer in detail.
Edit:
//String connect to SQL server
String url = "jdbc:sqlserver://" + strServerIPAddress + ":143...
This is a modification of code from the Java tutorial on Concurrency
package threads;
public class SimpleThreads {
static void threadMessage(String msg) {
String threadName = Thread.currentThread().getName();
System.out.format("%s: %s%n", threadName,msg);
}
private static class MessageLoop implements Runnable{
@Override
pub...
For some reason this code is printing three values for the highest value in the array when I'm trying to print just one (which is 11.3). Can someone please explain to me why it is doing this?
Thanks.
import java.util.Scanner;
public class Slide24
{
public static void main (String [] args)
{
Scanner in = new Scanner(Sys...
import java.net.*;
import java.io.IOException;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PortScanner {
public static void main(String[] args) {
InetAddress ia=null;
String host=null;
try {
host=JOptionPane.showInputDialog("Enter the Host name to scan:\n example: xx...
Is there equivalent of <? extends T> <? super T> in c++?
Also, does <? extends T> <? super T> work even if T is an interface in Java?
...
Does any weird errors comes when the code is compiled with one Java version and if it is deployed on different versions?
On our dev(Windows) machine, we are using JDK.1.4.2_13 and in QA (test) and Prod[Both are UX boxes] its JDK.1.4.2_9.
Am not talking about the major versions, but the minor versions/updates!
I agree its nice if it i...