Skip to main content

Posts

Showing posts from November, 2012

Reading and Writing Properties file in Java

Reading and Writing Properties file Java import java.io.FileInputStream; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; public class App {     @SuppressWarnings("rawtypes") public static void main( String[] args )     {           Properties prop = new Properties();         try {          // Loading Property file          // This method to load file in Simple Java Application.                 prop.load(new FileInputStream("messages.properties"));                                  // This method to load file when developing web application                 //prop.load(this.getClass().getClassLoader().getResourceAsStream("messages.properties"));                                  // Start ::                 //Writing Content to Property file                 prop.setProperty("ID121", "Angad Yadav");                 prop.setProperty("ID122", "Mani

HelloWorld Sample Application in Spring 3.0

Step 1: Open your Eclipse IDE, create a new Project under Dynamic Web Project Step 2: Download the jar file 1. commons-io-1.2.jar 2. commons-logging-1.1.1.jar 3. jstl-1.2.jar 4. log4j-1.2.14.jar 5. servlet-2.3.jar 6. slf4j-api-1.5.6.jar 7. slf4j-log4j12-1.5.6.jar 8. spring-asm-3.0.3.RELEASE.jar 9. spring-beans-3.0.3.RELEASE.jar 10.spring-context-3.0.3.RELEASE.jar 11.spring-core-3.0.3.RELEASE.jar 12.spring-expression-3.0.3.RELEASE.jar 13.spring-web-3.0.3.RELEASE.jar 14.spring-webmvc-3.0.3.RELEASE.jar 15.validation-api-1.0.0.GA.jar Now create lib folder under WEB-INF folder and copy all the jar files inside lib folder Now add these jar file to the project. Step 3: 1. Create index.jsp inside WebContent folder. 2. Create hello.jsp inside WEB-INF/views/ folder. 3. Create dispatcher-servlet.xml under WEB-INF folder. 4. Create package name controller and create class HelloWorldController.java inside package controller. for more detail refer below figure.

Creating Pdf in multiple Languages in Java

Creating Pdf in multiple Languages in Java This code demonstrate how to create pdf in multiple languages in java by using ITEXT pdf creator. To use this sample code download itext.jar To display different locale on pdf you need to download font known as Arialuni.ttf and added to the project Most important thing is the encoding part set encoding to "Identity-H" (String encoding = "Identity-H";) as well as create font for the same to take effect in pdf create font (Font fontNormal = FontFactory.getFont(("c:/windows/fonts/arialuni.ttf"), encoding,BaseFont.EMBEDDED, 8, Font.NORMAL);) You can download the source code from here import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.HeaderFooter; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.