JSON parser error with java:

I would like to parse a json file, here is my code: import org.json.JSONArray; import org.json.JSONObject; public class principale { public static void main(String[] args) { // TODO Auto-generated method stub String fichier ="C:\\listesanscoord.json&

Load the document on WebView with JSOUP

I'm trying to parse a part of webpage to WebView. I'm using jsoup library to get part of page that i need, and then load to webview. Here is code: public void loadArticleWithHTML (){ Thread downloadThread = new Thread() { public void run() { try { do

Create a string in java from a text file

I have a text file that has a list of User IDs looking like this; 798574 890859 984058 484849 etc... How can I read this text file into Java and then create a single string that wraps each ID in quotes and separates them by a comma like this? '798574

UDP Java does not send a message

Hello friends how are you? I am trying to send a udp message and I look for it in wireshark and I wont seem to find it can any of you tell me is there a problem here? or find me a solution? Thank you! DatagramSocket socket = new DatagramSocket(5500);

Palindrome with recursion; index out of range

I'm trying to write a function that checks whether a string variable is a palindrome or not. I can't find the reason this code throws IndexOutOfBoundException. I've tried to use examples so as to follow the result, but I still can't see where the exc

Java jTable sort percentage values ​​do not work

I was wondering why my jTable is not sorting percentage values and how I can fix this? I was hoping that I could convert the whole row into a string but that still doesn't work. What am I doing wrong? Thanks package tables; import java.awt.BorderLayo

List of files from the src folder

I want to list all files, that are located in a folder named icons. But the special feature is, that I want to start ot from the src folder in Eclipse. I want to use something like this: File f = new File("src/icons"); File[] fileArray = f.listF

Android - What should I use to get remote db data?

I'm working on an Android app that uses data stored in a remote database. I'm now working with Parse.com for my data storage but I might change to mysql. What structure should I use to load the data on to my screen? The data are objects that I want t

Volatile Uses Without Synchronization

Knowing that Reads and writes are atomic for all variables declared volatile Question1: Can this be understood as if private volatile int x = 0; x++; operation is atomic? And that Marking variable volatile does not eliminate all need to synchronize a

Uploading the file to the apache server using httppost

Thanks in advance for helping me everytime when i ask u questions. Btw this is not homework related question. I am currently trying to upload file / images on to my apache server from AVD. I'm not getting any errors when i execute my code, but image

Automatic vending machine for postage stamps

I was given an assignment to develop an algorithm for dispensing stamps for a postage stamp vending machine. I need to write a function that will return the minimum number of stamps for a given value. We can assume that there will always be a one cen

Dependency Injection with Jersey

If I am using Jersey 1.12, and I have multiple resource classes, and they all need to access some shared context, what's the best way to inject a dependency, whether it be in the constructor for the resource class, or into the handler method? Do I ne

Is the plug open all the time or simply open when necessary?

I'm coding an application where the client app needs to authenticate with a server to log in and the every half hour send a packet and receive some info and then sleep for another half hour. Would the proper way be to start the socket everytime and c

multiply decimal numbers in java

I have the following code which works when I am multiplying whole numbers however when I try to multiply decimal numbers and display the answer as a decimal number I am getting an error public void actionPerformed(ActionEvent e) { int num1=Integer.pa

How to write an if statement that resembles the SQL IN clause?

Is there any better way of writing the following expression like IN clause in SQL? int x; if (x == 1 || x == 2 || x ==3 || x == 4 ...) { //Doing something useful } I want to write something like below: if (x in (1,2,3,4,...)) {} I would just go with

Returning Jersey URLs

Inside a Jersey REST method I would like to forward to an another website. How can I achieve that? @Path("/") public class News { @GET @Produces(MediaType.TEXT_HTML) @Path("go/{news_id}") public String getForwardNews( @PathParam("

How can I use JPA to search for a substring on a field?

My application uses JPA to access the backend database. I have a Java class mapped to a table. The class has a string field (called status) that consists of a series of "0"s and "1"s. I need to select a few records based on the field's

Is Java free to use?

From what i understand Java is under the GPL license. What does this actually mean? can I use Java and its libraries for comercial apps without being restricted by GPL ?Yes. And just in case you're a visual learner:

Java createNewFile () - will it create directories?

I've got a conditional to check if a certain file exists before proceeding (./logs/error.log). If it isn't found I want to create it. However, will File tmp = new File("logs/error.log"); tmp.createNewFile(); also create logs/ if it doesn't exist

Try to determine which algorithm to use

You have an input a n games. Each game has a fame (which can be negative) and prerequisite games (these games must be played before you play the current game). You want to find the maximum amount of fame you can gain by playing a valid set of games.

Removal Issues

I have a class that extends the LinkedList class. Here's an excerpt of the code: class SortedList<Integer> extends LinkedList<Integer> { int intMethod(Integer integerObject){ return integerObject; } } This is expected to return the auto-unboxe

Problem with a Java thread that captures sound card data

I have a program which creates a thread that captures data from the soundcard at 48 KHz and writes it to a buffer for collection. The heart of the thread code is as follows .. public void run() { // Run continously for (;;) { // get data from the aud

Eclipse Command Line Java

I would like to see the command that Eclipse is running when I hit run for a Java program. I've looked around the Eclipse preferences for Run/Debug (and console) and the Run Configurations, but to no avail. How can I see the line that Eclipse is usin

Set the background color for JTabbedPane

I am using Nimbus Look and feel. I needs to change the Background color and foreground color of the tab in JTabbedPane but the color doesn't set in JTabbedPane. I tried setForeground(), setForegroundAt(), setBackground() and setBackgroundAt() methods

Put incorrect values.getModel in onBindAndValidate

I want to add some data to model if there wasn't any validation errors. I thought I could do this in onBindAndValidate, where I have the access to error object, which contains model: errors.getModel().putAll(map); I also tried to put values one by on