java

Iterating over bidimensional Java arrays.

public static List<Vertex<Integer>> petersenGraph() { List<Vertex<Integer>> v = new ArrayList<Vertex<Integer>>(); for (int i = 0; i < 10; i++) { v.add(new Vertex<Integer>(i)); } int[][] edges = {{0,1}, {1,0}, {1,2}, {2,1}, {2,3}, {3,2}, {3,4}, {4,3}, {4,0}, {0,4}, {5,6}, {6,5}, {6,7}, {7,6}, {7,8}, {...

JUnit produces strange AssertionFailedError

I am currently using JUnit 4.4 and Java 1.6.x. And after a recent code fix, we started getting this AssertionFailedError in my JUnit tests on the method: UtilityTest.testParseDate(4t): Mon Jan 15 09:26:07 PST 2001 expected: "Mon Jan 15 09:26:07 PST 2001" but was: "Mon Jan 15 09:26:07 PST 2001" junit.framework.AssertionFailedError: Util...

FileNotFoundException thrown when the file does exists.

Hello. I'm facing this strange problem. I'm trying to read a file that is located in another machine as a shared resource: \\remote-machine\dir\MyFileHere.txt When I run a standalone application ( a 16 lines java file ) everything is just fine. But when I attempt to read the same file with using the same class and the same method fr...

How to solve refreshing issues in Facelets and Spring Web Flow?

For my particular project, I'm using Facelets (1.1.14), MyFaces (1.2.3), and Spring Web Flow (2.0.3). My IDE is JDeveloper 10.1.3.3. My browser is IE6 (work requirement). Okay...ran into a very weird issue today. Normally, when I'm using Facelets, I can make whatever changes I want to my xhtml file, refresh my browser window, and s...

Cool uses of Attributes or Annotations (CLR or Java)?

What are some cool applications for custom attributes in CLR/C# code that you've done or heard about? Also interesting new uses of the standard attributes is also ok! Edit: Since Java's annotations seems to be the same as CLR's attrbutes, uses of Java annotations is also valid. ...

How to intercept xml response and request during web service invocation?

I wonder if there is some neat way to intercept xml request send during java webservice method invocation and xml given in response? I don't want to print those xmls to standard output but to "catch" them in some string. ...

Using JNDI to get a user's group name in Windows XP

Hi all, I have heard - and I'm not sure if it was from a credible source or from someone who actually has done it - that JNDI can be used to access a user's group name in windows. I am using Windows XP. I'm not sure how it works exactly but it sounds windows uses active directory to manage groups (can someone confirm?) and JNDI might ...

"LinkedHashMap" in C# 3.0

I wonder if there is a counterpart to java.util.LinkedHashMap in C#? (ie. the elements are (re)ordered automatically if I access an element. (boolean accessOrder) ). ...

How to handle stale connections?

Hi Friends, Ours is a J2EE app, using Struts-EJB-Hibernate on Websphere 6.1 over Mainframe/DB2 backend, that was recently moved to production. We are getting stale connection exception when the user login to the application first time or some times this exception occurs intermittently. on the second try the user able to log in to th...

Java: Round to arbitrary values

In Java, how do I round to an arbitrary value? Specifically, I want to round to .0025 steps, that is: 0.032611 -> 0.0325 0.034143 -> 0.0350 0.035233 -> 0.0350 0.037777 -> 0.0375 ... Any ideas or libs? ...

Is usage of anonymous classes in Java considered bad style or good?

I know anonymous classes save typing, if it comes to implementing Listener and similar stuff. They try to be a replacement for some usages of closures. But what does the community think about the value of these language-feature? Does it make sense and you use it regularly? Makes the saved typing the code clearer, more understandable and...

How to Check Path is existing or not in java?

Hi All: I have a java program which take path as argument. I want to check whether given path is existing or not before doing other validation. Eg: If i give a path D:\Log\Sample which is not not exist, it has to throw filenotfound exception. How can i do that? ...

Best Practice for Using Java System Properties

Our code uses a lot of system properties eg, 'java.io.tmpdir', 'user.home', 'user.name' etc. We do not have any constants defined for these anywhere (and neither does java I think) or any other clever thing for dealing with them so they are in plain text littered throughout the code. String tempFolderPath = System.getProperty("java.io.t...

Java http download corrupts file

Hello all! I have a problem, which I do not seem to be able to solve... I do a http download of a file, but the CRC32 of the file on the server and on the client do not match. Also, the file has different size, so obviously I must be doing something wrong... when I download via Firefox, the filesize is ok... so I guess it is somewhere i...

What are the methode we can use for LBS mobile application?

As far as i know there will be two methode till date i know: 1)Cell_Id... 2)CBS..... To display location on moble phone of base station. If please anybody know any other methode then please reply soon..... ...

Java web application properties

Does Java and/or Spring have the concept of properties? I have bunch of domain models, each of which has several properties. Example: public class Person { private String name; private Date dateOfBirth; private float height; private float weight; // getters and setters not shown } When displaying a person, the prop...

Best designs for breaking down business logic and data layer when they seem to overlap?

I'm building a MVC web application (using the Spring MVC framework), and I'm a little stumped on the best way to design a particular area. The application has to interact with a series of web services which are not really all that greatly designed, and don't offer much abstraction in and of themselves - basically there is a web service ...

Howto pass Java system properties to maven-cargo container

I'm preparing a maven2 web project for continuous integration. I use the maven cargo plugin to automatically deploy the WAR to Tomcat6x before running integration tests. My code depends on some system properties which are set with MAVEN_OPTS=-Dfoo=bar. Unfortunately these properties are missing when the application is deployed to Tomcat...

Java phone number format API

I have a database with millions of phone numbers with free-for-all formatting. Ie, the UI does not enforce any constraints and the users are typing in whatever they want. What I'm looking for is a Java API that can make a best-effort to convert these into a consistent format. Ideally, the API would take the free text value and a country...

How much of a transition is programming Java to iPhone apps?

I'm a highly skilled Java dev contemplating learning iPhone development. Mac only dev aspects aside, how much of a leap would learning the mobile application stack be? Sure I understand that its closer to C in how one should approach it, and with that comes memory management and so on. My queries would also include How well is OOP/O...