Skip to content

Instantly share code, notes, and snippets.

View uttesh's full-sized avatar
👨‍💻

uttesh uttesh

👨‍💻
View GitHub Profile
@uttesh
uttesh / sample.java
Created August 25, 2012 18:08
Find Number of duplicates present in a ArrayList
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
list.add(67);
list.add(32);
list.add(6);
list.add(4);
list.add(67);
list.add(3);
list.add(6);
@uttesh
uttesh / java.util.ConcurrentModificationException.java
Created August 26, 2012 14:40
CopyOnWriteArrayList difference with normal ArrayList
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/*
* Difference between ArrayList and CopyOnWriteArrayList
*/
public class CopyOnWriteArrayListTest {
@uttesh
uttesh / TimeZoneConvertor.java
Created September 1, 2012 06:35
TimeZoneConvertor with DST
import java.sql.Timestamp;
import java.util.TimeZone;
import java.util.logging.Logger;
import java.util.*;
public class TimeZoneConvertor {
private static final TimeZone defaultTimeZone = TimeZone.getDefault();
private static final Logger log = Logger.getLogger("TimeZone Convertor");
@uttesh
uttesh / UserControllerTest.java
Created September 5, 2012 16:41
Spring REST web service test
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.client.RestTemplate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
<property name="new.package" value="uttesh.xxx.yyy" />
<target name="package_rename" >
<replaceregexp
match="import xxx.yyy*"
replace="import ${new.package}"
byline="true">
<fileset dir="${src.main.dir}/java/uttesh/xxx/yyy/">
<include name="**/*.java"/>
</fileset>
ClientAbortException: java.io.IOException
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:368)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
........
Caused by: java.io.IOException
at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:712)
at org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:742)
@uttesh
uttesh / AmazonTests.java
Last active December 29, 2015 13:09
remote webdriver load for selenium grid
package com.rivetsystems.seleniumjunit;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
@uttesh
uttesh / Customer
Created February 16, 2015 09:32
Jaxb model class
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Rivet Systems
*/
@XmlRootElement
public class Customer {
@uttesh
uttesh / JsonStringGenerate
Last active August 29, 2015 14:15
Generate/Read the Json string
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author Rivet Systems
@uttesh
uttesh / JSONReader
Created February 16, 2015 11:06
Using org.codehaus.jackson read json string
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
/**
*
* @author Rivet Systems
*/
public class JSONReader {