Pages Navigation Menu

Coding is much easier than you think

RECENT POSTS

Read Excel with Java (Jexcel-api)

Posted by in Java, Java Excel

Read Excel with Java (Jexcel-api)

  In our previous article we have In our next article I have implemented Write Excel in Java using Jexcel-api in this article demonstrate how to read Excel files with the Java Excel API.   Since I have explained about Jexcel api in my previous article, so I’m not going to explain here again.   Download – Java Excel library   package com.simplecode.reader; import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.CellType; import jxl.Sheet; import...

read more

Write Excel with Java (Jexcel-api)

Posted by in Java, Java Excel

Write Excel with Java (Jexcel-api)

  This article demonstrate how to create Excel files with the Java Excel API.   ExcelApi – one of a number of open-source java Excel API, designed for reading, writing, and editing of dynamic excel. Among its features are: Reading from the book Excel 95, 97, 2000, XP, and 2003 Reading and writing formulas Creating a list in Excel 2000 Support for formatting fonts, numbers and dates Support colors, borders, and colors of cells Changing existing books excel Localization support Copying charts Copying and pasting drawings Logging...

read more

List FactoryBean, Set FactoryBean and Map FactoryBean

Posted by in Spring

List FactoryBean, Set FactoryBean and Map FactoryBean

  Download It List FactoryBean, Set FactoryBean and Map FactoryBean   We have previously seen how to deal with List, Set and Map type attributes inside a bean class. Further let us venture into having concrete List collection (ArrayList and LinkedList), Set collection(HashSet and TreeSet)  Map collection(HashMap and TreeMap)   Step 1 : Create the POJO   File : ClassABC.java   package com.simpleCodeStuffs; import java.util.List; import java.util.Map; import java.util.Set; public...

read more

Using life cycle events on a bean

Posted by in Spring, Spring Tutorial

Using life cycle events on a bean

  Download It using lifecycle events on a bean   The life cycle events of a bean can be used to set values to the attributes of a bean using the init method. We can associate the life cycle events of a bean to make calls to corresponding init and destroy method. The init and destroy method associated with a bean are given along with the bean definition. This way, a call is automatically made to these methods, as per the bean’s state. Init method is called once the property of the bean is set. Destroy...

read more

JDBC Performance Tuning

Posted by in Java, JDBC

     1.0 Introduction   In general Getting database connection is very expensive. If your application requires database connection that is repeatedly opened and closed, then this can become a significant performance issue. In this article let us learn some best way by which we can increase the performance.    2.0 Control transaction- Auto-Commit   In JDBC, transaction is a set of one or more statements that execute as a single unit.   java.sql.Connection interface provides some methods to control transaction...

read more

Convert Exponential form to Decimal number format in Java

Posted by in Java

Convert Exponential form to Decimal number format in Java

    In Java you will see that most of the values are displayed in Exponential form while using Doubles and Long.   Example: In the following example we are multiplying/dividing 7.35 with 1000000000 and following result is printed.   //Multiplication example Double a = 7.35d * 1000000000; System.out.println(a.doubleValue());   Result: 7.35E9   //Division example Double a = 7.35d / 100000; System.out.println("1) " + a.doubleValue());   Result: 7.35E-5   Thus you can see...

read more

Accessing Map and List attributes in spEL

Posted by in Spring, Spring Tutorial

Accessing Map and List attributes in spEL

  Download It – €“Accessing Map and List attributes in spEL Step 1 :Create the POJO   The bean is defined using @Component annotation. The values of the Map and List are set in the constructor. File : Bean.java   package com.simpleCodeStuffs.spEL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.stereotype.Component; @Component("testBean") public class Bean { private Map<String, String>...

read more

Overview on Log4j Levels

Posted by in Java, log4j

Overview on Log4j Levels

  Most often we deal with logging in our projects to log levels but tend to forget its role and definition of each. This post is for viewers who wish to refresh their knowledge in it. In this post we shall learn about different levels of logging in log4j and their usage.   Log4j has three main components: loggers: Responsible for capturing logging information. appenders : Responsible for publishing logging information to various preferred destinations. layouts: Responsible to format logging information in different...

read more

Auto Scale TextView Text to Fit within Bounds

Posted by in Android

Auto Scale TextView Text to Fit within Bounds

    1. You can create a Class to check for the TextView size 2. Edit the text view size to the maximum size allotted.   public FitView(Context context, AttributeSet attrs) { super(context, attrs); float size = this.getTextSize(); if (size > MAX_TEXT_SIZE) setTextSize(MAX_TEXT_SIZE); }   3. Then create an object for the Class in your activity. The constructor will be called automatically and resizing will be done. This resized TextView will be stored in the object created...

read more

How do I pass data between activities in Android

Posted by in Android

How do I pass data between activities in Android

  You may have persistent data such as session id to be used throughout the application in many activities. You may do this using any one of the following methods:   ** UPDATE: Android Complete tutorial now available here.   1. In the First Activity where the common value is first initiated, create a new Intent as below:   Intent i = new Intent(getApplicationContext(), NewActivity.class); i.putExtra("session_id","value"); startActivity(i);   You are adding the session value in the extras of...

read more