Skip to content

Tag: java

Using Java nio to create a subdirectory and file

I’m creating a simple program that will try to read in “conf/conf.xml” from disk, but if this file or dir doesn’t exist will instead create them. I can do this using the following code: My questions is if this really the most elegant way to do this? It seems superflous to need to creat…

Formatting Output in Java from ArrayList [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 years ago. Improve this question I’m trying to format my output of Marks from 2 different ArrayLists. One for Homework,…

How do I set JVM options for GradleWorkerMain?

When I set GRADLE_OPTS or JAVA_OPTS, these are set for GradleWrapperMain when I run ./gradlew build for my project. But I need them to be set for GradleWorkerMain as well. How do I do that? Here’s the ps listing when that Gradle job is running in Bamboo. My JAVA_OPTS (such as -Dcool.opt=1) is missing fr…

Convert a Bundle to JSON

I’d like to convert the an Intent’s extras Bundle into a JSONObject so that I can pass it to/from JavaScript. Is there a quick or best way to do this conversion? It would be alright if not all possible Bundles will work. Answer You can use Bundle#keySet() to get a list of keys that a Bundle contai…

Access Visual FoxPro database from Java

I’ve been trying to access a Visual Fox Pro database from Java for a week now. I’m getting desperate because my project is in a very tied budget and timeframe. (As any other project, I guess, hahaha) I have a .dbf, a .cdx and a .fpt files. I need to be able to look for a record, extract data, and

TestNG. can’t run a single test method

I have Selenium+Eclipse+Java Project+Eclipse TestNG plugin. For example, my code is: When i run TestClass as TestNG, both tests are executed. I can’t understand why test2 is executed also. Because there is a comment “//” before @Test annotations. Any ideas? thanks in advance Answer First, yo…

Executing Java code inside a Java program

I would like to create an application which for example measures the execution time of a certain block of code. In this case it should have a structure like this: I’m curious about the method designated by the arrow, I need some sort of a placeholder. How should be this method implemented? Is it even po…