Skip to content

Tag: java

Generate a image with custom text in Android

I’m trying to make an app for create custom cards. I’d like to add some text over a custom background (a jpg image). What is the best way of doing it? I’d need to show the user a preview of the card before send it to the server. Thanks Answer Use below code to achieve your requirement You ha…

Cast Double to Integer in Java

Any way to cast java.lang.Double to java.lang.Integer? It throws an exception “java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer” Answer A Double is not an Integer, so the cast won’t work. Note the difference between the Double class and the double primitive.…

Unix grep for Java logs

I am new to Unix grep and i would like some help to come up with a grep command. Currently, i have the following types of error in my application logs: 2012-02-31 10:21:41,333 ERROR [65] (GeneralAppliancesBean.java:135) – Exception java.net.ConnectException: Connection timed out 2012-01-31 10:24:41,843 …

Lucene: Multi-word phrases as search terms

I’m trying to make a searchable phone/local business directory using Apache Lucene. I have fields for street name, business name, phone number etc. The problem that I’m having is that when I try to search by street where the street name has multiple words (e.g. ‘the crescent’), no resu…

data from sqlite into ArrayList

i am using code this blog to have a draggable list. This tutorial is using a custom DragNDropAdapter that takes the content as an ArrayList. In my listActivity i query a table with returned column name.It has 11 values inserted. i tried to convert it to ArrayList from String[] with many ways such as : or what…

Regex to match words of a certain length

I would like to know the regex to match words such that the words have a maximum length. for eg, if a word is of maximum 10 characters in length, I would like the regex to match, but if the length exceeds 10, then the regex should not match. I tried but that brings me matches only if the minimum

Convert LocalDate to LocalDateTime or java.sql.Timestamp

I am using JodaTime 1.6.2. I have a LocalDate that I need to convert to either a (Joda) LocalDateTime, or a java.sqlTimestamp for ormapping. The reason for this is I have figured out how to convert between a LocalDateTime and a java.sql.Timestamp: So, if I can just convert between LocalDate and LocalDateTime,…