Recent Notes

Displaying keyword search results 131 - 140
Created by alfa on April 04, 2011 18:09:43    Last update: April 08, 2011 12:27:11
import java.awt.Graphics; import java.awt.event...
Created by alfa on April 08, 2011 11:05:24    Last update: April 08, 2011 11:05:24
Key points: Use java.awt.Robot to capture a screen region as java.awt.image.BufferedImage . Use javax.imageio.ImageIO to write image out to a file. import java.awt.AWTException; import java.awt.R...
Created by nogeek on April 07, 2011 21:30:54    Last update: April 07, 2011 21:30:54
This is the opposite of parsing. You can use javax.xml.transform.Transformer to output a DOM tree to a file. import java.io.*; import javax.xml.parsers.Docu...
Created by nogeek on April 07, 2011 21:07:55    Last update: April 07, 2011 21:07:55
You can use the javax.xml.transform.Transformer class to "transform" an XML stream (string in this case) to a DOM tree - effectively parsing the XML string. import java.io.*; import javax.xml.transform.Tr...
Created by nogeek on April 07, 2011 20:54:17    Last update: April 07, 2011 20:54:17
Use javax.xml.parsers.DocumentBuilder to parse xml. DocumentBuilder.parse() takes: java.io.File org.xml.sax.InputSource java.io.InputStream java.lang.String as a URI to an XML document Example code: import java.io.*; import javax.xml.parsers.Docu...
Created by freyo on April 06, 2011 14:50:01    Last update: April 06, 2011 15:00:03
C:\tmp>keytool -printcert -file CERT.pem keytoo...
Created by alfa on April 06, 2011 13:23:40    Last update: April 06, 2011 13:23:40
A file can be read as URL with the java.net package. You must provide absolute path after the URI scheme name file:// . package com.demo.io; import java.io.*; i...
Created by alfa on April 06, 2011 12:48:44    Last update: April 06, 2011 12:48:44
package com.demo.io; import java.io.*; ...
Created by alfa on April 06, 2011 12:07:12    Last update: April 06, 2011 12:08:01
You can use Class.getresourceAsStream or ClassLoader.getresourceAsStream to read a file from classpath. Class.getresourceAsStream delegates to ClassLoader.getresourceAsStream , but it does some preprocessing before delegation: If the file name begins with a '/', then the absolute name of the resource is the portion of the name following the '/'. Otherwise, the absolute name is: package_name_with_dot_replaced_by_slash/file_name package com.demo.io; import java.io.*; ...
Created by Dr. Xi on April 05, 2011 08:34:17    Last update: April 05, 2011 08:35:06
The Java servlet API does not provide a getStatus method for HttpServletResponse until version 3.0. This is a wrapper that provides getStatus for servlet API 2.5 and older. You have to override 4 methods because sendError etc. does not call setStatus . import javax.servlet.*; import javax.servlet.ht... You can plug it in a servlet filter like this: public void doFilter(ServletRequest req, ...