This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createThumbnail(String filename, int thumbWidth, int thumbHeight, int quality, String outFilename) | |
throws InterruptedException, FileNotFoundException, IOException | |
{ | |
// load image from filename | |
Image image = Toolkit.getDefaultToolkit().getImage(filename); | |
MediaTracker mediaTracker = new MediaTracker(new Container()); | |
mediaTracker.addImage(image, 0); | |
mediaTracker.waitForID(0); | |
// use this to test for errors at this point: System.out.println(mediaTracker.isErrorAny()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://viralpatel.net/blogs/2009/02/creating-parsing-json-data-with-java-servlet-struts-jsp-json.html | |
//http://viralpatel.net/blogs/download/json/json-rpc-1.0.jar | |
import org.json.JSONObject; | |
... | |
... | |
JSONObject json = new JSONObject(); | |
json.put("city", "Mumbai"); | |
json.put("country", "India"); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://viralpatel.net/blogs/2009/04/generate-pdf-file-in-java-using-itext-jar.html | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.OutputStream; | |
import java.util.Date; | |
import com.lowagie.text.Document; | |
import com.lowagie.text.Paragraph; | |
import com.lowagie.text.pdf.PdfWriter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://viralpatel.net/blogs/2009/04/http-proxy-setting-java-setting-proxy-java.html | |
System.getProperties().put("http.proxyHost", "someProxyURL"); | |
System.getProperties().put("http.proxyPort", "someProxyPort"); | |
System.getProperties().put("http.proxyUser", "someUserName"); | |
System.getProperties().put("http.proxyPassword", "somePassword"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://viralpatel.net/blogs/2009/01/how-to-take-screen-shots-in-java-taking-screenshots-java.html | |
import java.awt.Dimension; | |
import java.awt.Rectangle; | |
import java.awt.Robot; | |
import java.awt.Toolkit; | |
import java.awt.image.BufferedImage; | |
import javax.imageio.ImageIO; | |
import java.io.File; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.zip.*; | |
import java.io.*; | |
public class ZipIt { | |
public static void main(String args[]) throws IOException { | |
if (args.length < 2) { | |
System.err.println("usage: java ZipIt Zip.zip file1 file2 file3"); | |
System.exit(-1); | |
} | |
File zipFile = new File(args[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import org.apache.commons.lang.ArrayUtils; | |
public class Main { | |
public static void main(String[] args) { | |
String[][] countries = { { "United States", "New York" }, { "United Kingdom", "London" }, | |
{ "Netherland", "Amsterdam" }, { "Japan", "Tokyo" }, { "France", "Paris" } }; | |
Map countryCapitals = ArrayUtils.toMap(countries); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.mail.*; | |
import javax.mail.internet.*; | |
import java.util.*; | |
public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException | |
{ | |
boolean debug = false; | |
//Set the host smtp address | |
Properties props = new Properties(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OracleJdbcTest | |
{ | |
String driverClass = "oracle.jdbc.driver.OracleDriver"; | |
Connection con; | |
public void init(FileInputStream fs) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException | |
{ | |
Properties props = new Properties(); | |
props.load(fs); |