I was reading concept of type erasure in generics. While executing the below piece of code I got confused. public class CollectionsWild { void Test(Collection<?> t){ System.out.println("Collection"); } void Test(List<Integer> t){ Sys
I use this code to delete a file File dir = new File(Environment.getExternalStorageDirectory() + "/myapp/" + "/Media/"); if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { new File(d
Hi i'm using below code for find article using spring with plain hibernate. public List<Article> getArticles(int currPosition, int pageSize) { Criteria c = getSession().createCriteria(Article.class); c.addOrder(Order.desc("createdDate"));
There are many ways to analyze jvm memory usage offline, like MAT, jmap. However, is there any way to measure the memory usage inside the code during the runtime? Any advice will be much appreciated.Please refer to the official Java documentation, i.
My XML Short tag file <product> <a001>CRITICAL-62258</a001 ><a002>01</a002> <productidentifier> <b221>03</b221> <b244>9781911106050</b244> </productidentifier> <productidentifier> <
I am using the scopes: mail.send, mail.readwrite, mail.read, offline_access, openid, email, and profile (although I am fairly confident I do not need all of these -> goal is to read inbox and send emails, while also getting email and name if they exi
I made a Test where I send an invalid JSON, and it should catch me a JSONException. When I run the test, it fails and shows me a JSONException, Why doesn't test catch it? @Test (expected = JSONException.class) public void testExtraFieldsJsonException
I am using Java to try make a check on my server side on whether or not what the user sends over is in the hashmap, but my example will run with the name I've given regardless of whether its in the hashmap or not. Anyone know why this is happening? c
I am writing an android app but using JUnit to test it out some of the more java-specific functionality before creating activities and the android-specific functions. As I write out the JUnit tests and execute them bit by bit, I am finding failures a
I'm trying to send a file from a client to a server with Sockets in Java. It works fine when I am testing on the same machine, but when I test across different machines, I lose large chunks of data, resulting in a corrupted file. If I try to send a v
The following code in java, when run on elipse, gives same output even if we replace superclass s=new sub(); with, sub s= new sub(); Note that we have overridden methods. Output is: changed supermethod in sub class num is sub class 5 Code: public cla
I'm making a musicplayer in Processing for an assignment for school. The Philips Hue lights will make some corresponding visual effects. I wanted to make the visuals kinda unique for each song. So I fetched the cover art (using LastFM API) of the pla
Time now = new Time(); now.setToNow(); return "Time = ["+String.valueOf(now)+"]\n"; this is the result Time = [20131020T185424Asia/Bangkok(0,292,25200,0,1382270064)] 2013 = year 10 = month 20 = day 18 = hr 54 = min 24 = sec What does (
I tried below code, It works only for 1 array, when i try to add another, it throws an runtime exception Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.add(Unknown Source) at java.util.AbstractList.a
I am trying to write a Java program that when you click on a certain element in the JFrame, the background of a JLabel is changed. The function that the event handling method calls to change the background does not work when called from the event, ho
I'm trying to persist data with Play 2 using JPA, but i'm getting: Execution exception [IllegalArgumentException: Unknown entity: models.Stream]; Stream.java ` package models; import javax.persistence.Entity; import javax.persistence.EntityManager; i
How can I make the following method return a character array ? public char[] startThread() { // arr declaration Runnable r = new Runnable() { @Override public void run() { arr = getArray(); // arr assignment } }; new Thread(r).start(); return arr; }
I'm facing the following issue. With an etl configuration file I load some data from a Oracle DB Table than I export these data to a CSV file. However, when a field contains double quote (") this character is duplicated. I'll explain with a simple ex
Let say I have to used a two paragraph string in my java program. What would be the best approach on this? Should the paragraph saved in a file and retrieved when used? Or there are better approach?It depends. If the paragraphs will never change, the
I've never been good with regex and I can't seem to get this... I am trying to match statements along these lines (these are two lines in a text file I'm reading) Lname Fname 12.35 1 Jones Bananaman 7.1 3 Currently I am using this for a while stateme
I have an interface that I've exposed as a regular SOAP web service. One method of the interface consists for the client to send a file to the server, then the server processes the file and returns a result file. Processing the file may take some tim
Need to run maven jaxb2 plugin from my app, at run-time. Is it possible?Maybe i have done something that could help you: /** * @author swoeste * */ public class MavenExecutor { private final File configuration; private final ClassWorld classWorld; /*
I want to run a specific method doThis() (which is not a CPU intensive action, it's just a POST to a web server) every 10 minutes and when that method is finished executing, to notify the user (via Toast or Notification or something of the sort). But
Possible Duplicate: how to convert java string to Date object In my Java code I have input String like 05.10.2011 which I need to convert to milliseconds. So: String someDate = "05.10.2011"; I have to convert to match milliseconds format. String
I would like to have a JTextPane that have scroll bar, how can I do so ? Thanks.To insert a scroll bar on your new JTextPane, just use a JScrollPane: JTextPane txt = new JTextPane(); JScrollPane jsp = new JScrollPane(txt); JTextPane API: http://downl
public boolean isDoubleValue(String s) { try { Double.valueOf(s); return true; } catch (Exception e) { return false; } } But i want to convert this method into QT cpp. Can any one help me? Thanks, NagarajuSince you need it in Qt (from your comment),
I'm new to web services and I've been breaking my head trying to find a simple java SOAP client program on the Internet. All I want to do is send a SOAP message and receive back some response. There is a website which offers free web-services. http:/
Using a JEditorPane, is there any way to tell if the caret is currently on the last line? I cannot find anything in the API or more importantly JTextComponent of which JEditorPane is derived. I need to find this out when the user uses the down arrow
I'm trying to get a GWT 1.7 project to run using the new development mode. Pointing Safari (with the Development Mode plugin installed) to the given URL just shows the latest compiled version. No changes are reflected when I refresh. A clean 'hello w
Random.nextGaussian() is supposed to give random no.s with mean 0 and std deviation 1. Many no.s it generated are outside range of [-1,+1]. how can i set so that it gives normally distributed random no.s only in the range -1 to 1.A Gaussian distribut