I am trying to copy a file from an InputStream into a local directory. I created a local directory called test, and it is located in my package root. public void copyFileFromInputStream(InputStream is) { Path to = Paths.get("test"); Files.copy(i
This question already has an answer here: how to download image from any web page in java 7 answers I'm using jsf 2.2 Primefaces 6.0 and i already implemented a solution to download an images from the ressources file inside the application and it wor
I am, programmatically, creating a lot of LinearLayouts and putting them on another LinearLayout: public void loadList(){ LinearLayout linearLayout = (LinearLayout)findViewById(R.id.linearShowing); if(linearLayout.getChildCount() > 0) linearLayout.re
//c is an integer passed to count how many times the while looped before stopping public static int ask(String[] p, String[] n, int c) { int i = 0; while(p[i] != "stop") { p[i] = input("postcode ? "); n[i] = input("name ?");
I'm trying to use recursion to loop through the String array and input a "-" between repeating characters. Ex: "hello" would output to "hel-lo" This is my code so far: Main Class: public class L6C13PairStar { /** * @param arg
I have to get DateTime with using TimeZone and then get Timestamp from that DateTime My Code is give below : DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date dt = new Date(); String currentTime = formatter.format(dt); Sys
I am new to web services and I am trying to use RESTFul webservices. I am trying to pass parameter to RESTFul web server in Java from ajax. Here is what I did index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8">
I'm studying on hash table with chaining in java by its implementation. The trouble is about get() method. An index value is determined with key.hashCode() % table.length. Assume that the table size is 10 and key.hashCode() is 124 so index is found a
Written this code, would like to get better approach using any algorithm to find missing numbers from an sorted or unsorted array. If its an unsorted array, i would sort and execute the following. private static void identifyMissingValues(Integer[] a
In the following program, the user is supposed to enter a String (name of a City) and the program should return the index of the corresponding City in the array. But I get an error, in the subroutine indexCities the following message: "nameCity canno
I have created indexes and fields in ElasticSearch. I could successfully run Logstash config file to add data from MySQL database table into ElasticSearch using the following command : bin/logstash -f [PATH TO LOGSTASH CONFIG FILE] -v I need to run t
I have a class postedJobHistory (Fragment): public class PostedJobHistory extends Fragment { String employerName; private List<ParseObject> jobDetails; Context context; public PostedJobHistory() {} public PostedJobHistory(Context context, String emp
I have called a function returnCurrentNameById() by passing the id of the particular row. But it gives an error. String[] s1; public String[] returnCurrentNameById(int k) throws SQLException{ String[] columns = new String[]{ KEY_ID1, KEY_NAME, Key_DO
I have an instance of a JBoss EAP 6.1 where i deployed 2 EJB applications. The server starts without errors! Now I have created a javaSE application to call these EJBs. And here is the problem... If I make lookup of EJB from applicationA/EJBBean!br.c
I am getting security certificate errors in the code below (source). The exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcepti
I have written a code in java that help me to generate a pdf . I have used Itext libraries to generate it. This code also consists of database connectivity with postgres. I have used two jar files itextpdf-5.4.5.jar and postgresql-9.0-901.jar. But as
This works as supposed, test fails (due to haltTesting()) and is repeated 2x public class A0001_A0003Test extends TestControl { private Kunde kunde = Kunde.FR_WEHLITZ; @Test(retryAnalyzer = TestRepeat.class, groups = {TestGroups.FAILED}, description
I'm wondering how can I make a Java program delay parts of code to prevent spamming buttons/other things in the program. So let's just say I'm making a program that displays the amount of times a user has clicked a button. I would like there to be a
I have found some strange code, where I said "This is never called, because it would throw a class cast Exception". Well the code gets called and its working. Can anybody explain me: Why is this working? The method getZipList() is defined to ret
I am trying to read a 2.5GB txt file into my application. I am running Win7 x64 and have 43GB of mem available (out of 64GB). I tried playing around with -Xmx -XX:MaxParmSize -XX:ParmSize etc. None of these affect the error. What else could I try? Th
I tried adding another set of values to the demo example of stacked bar charts with achartengine, but the new values introduced by me don't appear on the chart. Is Stacking bars limited to two bars? public Intent getIntent(Context context) { String[]
This program works, except when the number of nJars is a multiple of 7, I will get an answer like $14.999999999999998. For 6, the output is 14.08. How do I fix exceptions for multiples of 7 so it will display something like $14.99? import java.util.S
I have in Eclipse web application project that depends from other projects. When I run debug on embedded Tomcat in lib folder that Eclipse copied not jars, but folders with names like: dependent_lib1.jar dependent_lib2.jar dependent_lib3.jar ........
I have to draw tick markers at 10 percent intervals starting at zero and going to 100 percent of the width of a graphical object. I would do something like: int width = 556; int k = width/10; for(int i = 0;i<width;i++){ if(i%k==0){ draw marker on gui
I'm making a simple calculator for this homework, and Java is returning "Infinity" when divided by 0. I need to display some error message, when I get infinity. The problem is I don't know how to do the condition double result; result = 4/0; //i
I was recently searching for an answer to a different question about load-time-weaving and autowiring and I remember coming across something like this, but I'm not sure how to configure it. Essentially, I have class instances created outside of my co
I'm new to DDD, and I'm trying to apply it in real life. There is no questions about such validation logic, as null check, empty strings check, etc - that goes directly to entity constructor/property. But where to put validation of some global rules
How can one perform set operations on a HashMap, such as Collections.addAll()?Based on you comments to the questions asked I think what you really need is a Set not a Map. Try Set<String> mySet = new HashSet<String>(); mySet.addAll(...); Use m
A servlet response wrapper is being used in a Servlet Filter. The idea is that the response is manipulated, with a 'nonce' value being injected into forms, as part of defence against CSRF attacks. The web app is using UTF-8 everywhere. When the Servl
I am confused as to the difference between the two. In my application I have just used Extends Activity and the application is working perfectly, so what is the purpose of Extends Application?. Would you use it on the first class you create in the An