Posts

Downloading Images Through PDFBox

RetrieveAndDownloadImages.java package com.hari.main.imageretrieve; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.apache.axiom.om.util.Base64; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.common.PDRectangle; import com.kwiktag.webservices.util.XmlUtil; import com.kwiktag.webservices.util.kwiktagUtils; import com.necho.platform.service.receiptretriever.ReceiptRetriever; import com.necho.platform.service.receiptupload.PDFDocumentHelper; import com.necho.platform.service.receiptupload.TIFFBilevelVerifierImpl; import com.necho.platform.service.receiptupload.TIFFInfoVO; import com.necho.platform.service.receiptupload.TIFFVerifier; public class RetrieveAndDownloadImages...

Reading And Writing Image Files using Java

GenerateOutputFileName.java --------------------------------------- import java.io.File; import java.io.IOException; import java.util.Date; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; public class GenerateOutputFileName { public static void main(String[] args) throws Exception{ File outputDirFile = new File("C:\\Users\\sivaleti\\Desktop\\Tmp"); String directoryName ="C:\\Users\\sivaleti\\Downloads\\Images\\"; String generatedFileDir ="C:\\Users\\sivaleti\\Desktop\\FTP1\\"; File folder = new File(directoryName); File[] listOfFiles = folder.listFiles(); System.out.println("Start :" + new Date()); for (int i = 0; i < listOfFiles.length; i++) { try { String fileExtension = getFileExtension(listOfFiles[i]); if(fileExtension.length() > 3 || fileExtension.equalsIgnoreCase("svg")) continue; String documentNumber = "N00100011111" + (2190137+i+1);...

Remote Debugging with Eclipse + WebSphere 8

Image
So far, there is still lack of WebSphere 7 plugin for both Eclipse and NetBeans IDE. However, you are able to debug your web application via  Java Debugger (jdb) . Here’s a guide to show you how to remote debugging your web application in Eclipse and WebSphere via Java Debugger (jdb). Eclipse < ---- > Java Debugger ( jdb ) < ---- > WebSphere 7 Copy 1. Enable WebSphere in Debug Mode In WebSphere web console, left navigation, 1. Servers –> Server Types –> WebSphere application servers 2. Under Server Infrastructure section –> expand Java and Process Management –> Process definition 3. Under Additional Properties section –> click Java Virtual Machine 4. Checked the “ Debug Mode ” 5. In Debug arguments textbox, put this - Xdebug - Xnoagent - Xrunjdwp : transport = dt_socket , server = y , suspend = n , address = 8888 Copy 6. Restart WebSphere server instance. Now, WebSphere is started in debug mode, and listening on port ...

Enabling WL-Proxy-SSL HTTP header in WebLogic

Scenario : Weblogic server will be always behind the LoadBalancer or Apache layer. Most of the time the SSL's will be either offloaded in LoadBalancer or Apache layer.  To construct applicaitons URL's with the right protocol will be a challenge while using weblogic as application server.  To achieve this scenario we have to enable  WL-Proxy-SSL  and  WebLogic Plug-In Enabled. Solution: - Update the LoadBalancer configurations/iRules to set the RequestHeader  WL-Proxy-SSL  to  true . - Follow the below steps to set the WebLogic 'Plugin Enabled' flag to Yes. (Following steps are based on the weblogic version 12.1.2)    - Login into weblogic console    - Click on Lock & Edit button     - Click on the domain name    - Under Configurations tab go to "Web Applications" sub tab    - Select the check box "WebLogic Plugin Enabled" and click "save" button    - Finally click on "...

Difference between Comparator and Comparable in Java

Comparable interface: Class whose objects to be sorted must implement this interface.In this,we have to implement compareTo(Object) method. For example: public class Country implements Comparable{ @Override public int compareTo(Object arg0) { Country country=(Country) arg0; return (this.countryId < country.countryId ) ? -1: (this.countryId > country.countryId ) ? 1:0 ; }} If any class implements comparable inteface then collection of that object can be sorted automatically using Collection.sort() or Arrays.sort().Object will be sort on the basis of compareTo method in that class. Objects which implement Comparable in java can be used as keys in a SortedMap like TreeMap or SortedSet like TreeSet without implementing any other interface. Comparator interface: Class whose objects to be sorted do not need to implement this interface.Some third class can implement this interface to sort.e.g.CountrySortByIdComparator class can i...

Multithreading and Concurrency Interview Questions and Answers

1. What do we understand by the term concurrency? Concurrency is the ability of a program to execute several computations simultaneously. This can be achieved by distributing the computations over the available CPU cores of a machine or even over different machines within the same network. 2. What is the difference between processes and threads? A process is an execution environment provided by the operating system that has its own set of private resources (e.g. memory, open files, etc.). Threads, in contrast to processes, live within a process and share their resources (memory, open files, etc.) with the other threads of the process. The ability to share resources between different threads makes thread more suitable for tasks where performance is a significant requirement. 3. In Java, what is a process and a thread? In Java, processes correspond to a running Java Virtual Machine (JVM) whereas threads live within the JVM and can be created and stopped by the Java application dynamicall...