Organize methods by type of return or argument?

I'm having a bit of a hard time articulating this problem. With different types, what considerations are there for how to organize methods that traverse the relationships to convert to a different type? While being forgiving about the precise modelli

Is there a FileReader equivalent for a Java URL?

This question already has an answer here: Read url to string in few lines of java code 8 answers Consider the following. val br = new BufferedReader(new FileReader(inputFileName)) But instead of a file, I want to read a file directly from the web, th

select the checkbox using selenium webdriver

i need to select checkbox which is having same ids HTML: <label class="table-checkbox-label" for="record-12034"> <input id="record-12034" class="table-checkbox" type="checkbox"/> </label>

Insertable object in a class with @IdClass annotation

Is it possible to do a cascade save in Section.class? I create Section object and add new questions without id. When I try save it I get error: org.postgresql.util.PSQLException: ERROR: insert or update on table "question_to_section" violates fo

Using table settings with SQL Server JDBC

Could anyone provide some guidance on how to use Table Value Parameters (TVP) with SQL Server JDBC? I am using the 6.0 version of the SQL Server driver provided by Microsoft, and I have reviewed the official documentation as well as the more helpful

Convert Int to ImageView

Here is some code: public class Article { (...) private static int[] sImages = { R.drawable.ic_picture}; private ImageView mImage; public Article(int a) { mImage = sImages[a]; } In: mImage = sImages[a]; There is this error: Incompatible types Require

How to use an enumeration as we would use an interface?

How can I assign SomeEnum1 or SomeEnum2 to an "enum" which implements SomeInterface? I can't just specify the interface directly as it's a class and not an enum. I'm sure there is a specify syntactic sugar to make this work but I can't figure it

Sorting a student array by last name alphabetically in Java

I currently have this program read the contents of a text file and calculate the averages and amount of test scores taken and print them out neatly in a small data table. These are the names, amount of quizes taken and average of each student: James

Checking int in an int array

I'm trying to find an integer inside of an int[] array and return true or false depending on whether or not it's present anywhere, however my code, which I've taken from numerous websites. My array is as follows: private static final int[] thirtyOneD

Detect when the idle ThreadPoolExecutor thread is killed

I am using ThreadPoolExecutor to manage the number of threads, I can catch the event of creating a new Thread for ThreadPool via ThreadFactory->newThread() But I do now know how to catch the event of killing Thread which stays idle for 2minutes as fo

What is the use of the main method in the abstract class?

I know that we can write main method in abstract class, but what we can achieve from it ? public abstract class Sample { public static void main(String args[]) { System.out.println("Abstract Class main method : "); } } We can not create the obje

inserting column headers in the hsqldb text file

I'm modifying someone else's Java code, learning Java as I go. :-). I'm writing hsqldb TEXT files, and I would like the final files to have a 'heading' row, so that they can be more easily understood as plain text. hsqldb has a switch 'ignore_first=t

Regarding the data read from the TCP connection

I am making a client socket connection with a hardware device. I am sending a command to this connection to be process by hardware. Now as a acknowledgment or as a reply, the hardware sends a response. The application sends a command to the connectio

Java, Mac OS, Windows and Linux

I have migrated from Linux (Ubuntu) to Mac OS. I have wrote an application in Java (swing). I have run it successfully the same code in windows and linux but in mac os I have some problems. Here is the code and problems in comments: public MainForm()

java: how to define a global thread ID?

Is there any possibility to set unique ID for a thread? In distributed system where threads are created on many different machines (e.g. by RMI)? I need it to create log messages. From my research I know that it can be done using log4j mdc/ndc, but o

Android Java How to connect an IP camera inside an activity

I am looking for any tip or guidance to develop an application like cam viewer. So i will see the live videos on my android application by using IP address and port. I searched this question but i could not find proper answer anywhere so please help

When to include what?

I created a class Person (as the book says) to hold the name and last name of a person entered from the keyboard and then there is another class PhoneNumber which encapsulates the country code, area code and the number of a person as a String. Person

Recognize the logo in a bitmap - Android

I'd like to detect if a logo image in user's camera view - for example if the logo of StackOverflow was printed on a paper and viewed through camera. Or for less complicated approach let's say that I'd like to detect it in a bitmap. I'd like to recog

how to create database data based on a dynamic text box

I need to design a JSF (or JSP) page where the text box vary dynamically based on key fields (fruits,Sweet, Biscuits ) . For example in a shop they have 3 product fruits (a,b,c), Biscuits (d,e) , Sweet s(f,g,h,I,j) if select Select Opption : Fruits |

The application is reduced on an Android 3.0 tablet

As seen here my app gets shrinked on Samsung Galaxy Tab with Android 3.0 It is also shrinked in emulator, but at graphical layout it looks ok. main.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientat

Prerequisite for TreeMap

Like for a object to be inserted into a HashMap the object should implement the equals() and the hashcode() method(not necessarily). Are there any special conditions for an object to be inserted in a TreeMap ?Unless a Comparator which mutually compar

Derby INSERT SELECT null pointer exception

I'm writing a Java application that's working with Apache Derby via JDBC. I'm having problems with the code in the following snippet: byte md5[] = md5sum(file); PreparedStatement s = con.prepareStatement("INSERT INTO input_files (job_ID, hash) SELECT

Java RMI - Client Timeout

I'm building a Distributed System using Java RMI and it must support a server loss. If my client is connected to a Server using RMI, if this server goes down (cable problems for example), my client should get an exception so it can connect to other s