Thursday, August 19, 2010

Extract list of urls from a given link

This program will help to extract list of urls from a given link .That is what ever links are there within that link all will be extracted.Example url for images,files,etc.
for these you have to use two api 1)jsoup-1.2.2.jar and 2)cayenne-1.2.1.jar

import org.apache.commons.lang.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.Jsoup;
import org.jsoup.select.Elements;

import java.net.URL;
import java.io.IOException;
import java.util.Iterator;
import java.util.TreeSet;

/**
* Example program to list links from a URL.
*/
public class ListLinks {
public static void main(String[] args1) throws IOException {

String[] args = {"http://www.mayoclinic.com/health/allergies/DS01118/DSECTION=symptoms"};
Validate.isTrue(args.length == 1, "usage: supply url to fetch");
URL url = new URL(args[0]);
print("Fetching %s...", url.toExternalForm());

Document doc = Jsoup.parse(url, 3*1000);
Elements links = doc.select("a[href]");
Elements media = doc.select("[src]");
Elements imports = doc.select("link[href]");

print("\nMedia: (%d)", media.size());
TreeSet mm = new TreeSet();
for (Element src : media) {
if (src.tagName().equals("img"))
{
print(" * %s: <%s> %sx%s (%s)",
src.tagName(), src.attr("abs:src"), src.attr("width"), src.attr("height"),
trim(src.attr("alt"), 20));
mm.add(src.attr("abs:src"));
}
else
print(" * %s: <%s>", src.tagName(), src.attr("abs:src"));
}

print("\nImports: (%d)", imports.size());
for (Element link : imports)
{
print(" * %s <%s> (%s)", link.tagName(),link.attr("abs:href"), link.attr("rel"));
}

print("\nLinks: (%d)", links.size());
for (Element link : links)
{
print(" * a: <%s> (%s)", link.attr("abs:href"), trim(link.text(), 35));
}

System.out.println("My OutPut");
Iterator ww = mm.iterator();
while(ww.hasNext())
{
System.out.println((String)ww.next());
}

}

private static void print(String msg, Object... args) {
System.out.println(String.format(msg, args));
}

private static String trim(String s, int width) {
if (s.length() > width)
return s.substring(0, width-1) + ".";
else
return s;
}
}

Tuesday, July 27, 2010

Different Java Versions

JDK 1.0 (january 23, 1996) oak
- Initial release


JDK 1.1 (february 19, 1997)
- Retooling of the AWT event model
- Inner classes added to the language
- JavaBeans
- JDBC
- RMI


J2SE 1.2 (December 8, 1998) playground
This and subsequent releases through J2SE 5.0 were rebranded retrospectively Java 2 & version name "J2SE"
(Java 2 platform, Standard edition) replaced JDK to distinguish the base platform from
J2EE (java 2 platform, enterprise edition) and J2ME (java 2 platform, micro edition).

- Strictfp keyword
- Reflection
- Swing api integration into the core classes
- JVM equipped with a jit compiler
- Java plug-in
- Java IDL
- An IDL implementation for corba interoperability
- Collections Framework


J2SE 1.3 (may 8, 2000) kestrel
- Hotspot jvm included
- JavaSound
- JNDI included in core libraries
- Java platform debugger architecture (jpda)
- RMI was modified to support optional compatibility with corba


J2SE 1.4 (february 6, 2002) merlin
- assert keyword
- Regular expressions
- Exception chaining (allows an exception to encapsulate original lower-level exception)
- Internet protocol version 6 (IPV6) support
- Non-blocking nio (new input/output)
- Logging API
- Image i/o api for reading and writing images in formats like jpeg and png
- Integrated XML parser and XSLT processor (JAXP)
- Integrated security and cryptography extensions (JCE, JSSE, JAAS)
- Java web start


J2SE 5.0 (september 30, 2004) tiger [originally numbered 1.5]
- Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
- Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
- Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
- Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
- Swing: new skinnable look and feel, called synth.
- Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string... Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
- Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
- Automatic stub generation for rmi objects.
- Static imports concurrency utilities in package java.util.concurrent.
- Scanner class for parsing data from various input streams and buffers.
- Assertions
- StringBuilder class (in java.lang package)
- Annotations



Java SE 6 (december 11, 2006) mustang
sun replaced the name "J2SE" with java se and dropped the ".0" from the version number.
Beta versions were released in february and june 2006, leading up to a final release that occurred on december 11, 2006.
The current revision is update 14 which was released in may 2009.

- Support for older win9x versions dropped.
- Scripting lang support: Generic API for integration with scripting languages, & built-in mozilla javascript rhino integration
- Dramatic performance improvements for the core platform, and swing.
- Improved web service support through JAX-WS JDBC 4.0 support
- Java compiler API: an API allowing a java program to select and invoke a java compiler programmatically.
- Upgrade of JAXB to version 2.0: including integration of a stax parser.
- Support for pluggable annotations
- Many GUI improvements, such as integration of swingworker in the API, table sorting and filtering, and true swing double-buffering (eliminating the gray-area effect).


Java se 6 update 10
A major enhancement in terms of end-user usability.
- Java Deployment Toolkit, a set of javascript functions to ease the deployment of applets and java web start applications.
- Java Kernel, a small installer including only the most commonly used jre classes. Enhanced updater.
- Enhanced versioning and pack200 support: server-side support is no longer required.
- Java quick starter, to improve cold start-up time.
- Improved performance of java2D graphics primitives on windows, using direct3D and hardware acceleration.
- A new Swing look and feel called NIMBUS and based on synth.
- Next-generation java plug-in: applets now run in a separate process and support many features of web start applications.


Java se 6 update 12
This release includes the highly anticipated 64-bit java plug-in (for 64-bit browsers only), windows server 2008 support,
and performance improvements of java and JAVAFX applications.

Tuesday, May 25, 2010

HTML ASCII Characters

HTML ASCII Characters
codes characters character names
32
ASCII: space (usually one em wide)
33 ! ASCII: exclamation mark
34 " ASCII: quotation mark
35 # ASCII: number sign
36 $ ASCII: dollar sign
37 % ASCII: percent sign
38 & ASCII: ampersand
39 ' ASCII: apostrophe-quote
40 ( ASCII: opening parenthesis
41 ) ASCII: closing parenthesis
42 * ASCII: asterisk
43 + ASCII: plus sign
44 , ASCII: comma
45 - ASCII: hyphen-minus
46 . ASCII: period
47 / ASCII: slash
48 0 ASCII: digit zero
49 1 ASCII: digit one
50 2 ASCII: digit two
51 3 ASCII: digit three
52 4 ASCII: digit four
53 5 ASCII: digit five
54 6 ASCII: digit six
55 7 ASCII: digit seven
56 8 ASCII: digit eight
57 9 ASCII: digit nine
58 : ASCII: colon
59 ; ASCII: semicolon
60 < ASCII: less-than sign
61 = ASCII: equals sign
62 > ASCII: greater-than sign
63 ? ASCII: question mark
64 @ ASCII: commercial at
65 A ASCII: Latin Capital Letter A
66 B ASCII: Latin Capital Letter B
67 C ASCII: Latin Capital Letter C
68 D ASCII: Latin Capital Letter D
69 E ASCII: Latin Capital Letter E
70 F ASCII: Latin Capital Letter F
71 G ASCII: Latin Capital Letter G
72 H ASCII: Latin Capital Letter H
73 I ASCII: Latin Capital Letter I
74 J ASCII: Latin Capital Letter J
75 K ASCII: Latin Capital Letter K
76 L ASCII: Latin Capital Letter L
77 M ASCII: Latin Capital Letter M
78 N ASCII: Latin Capital Letter N
79 O ASCII: Latin Capital Letter O
80 P ASCII: Latin Capital Letter P
81 Q ASCII: Latin Capital Letter Q
82 R ASCII: Latin Capital Letter R
83 S ASCII: Latin Capital Letter S
84 T ASCII: Latin Capital Letter T
85 U ASCII: Latin Capital Letter U
86 V ASCII: Latin Capital Letter V
87 W ASCII: Latin Capital Letter W
88 X ASCII: Latin Capital Letter X
89 Y ASCII: Latin Capital Letter Y
90 Z ASCII: Latin Capital Letter Z
91 [ ASCII: opening square bracket
92 \ ASCII: backslash
93 ] ASCII: closing square bracket
94 ^ ASCII: spacing circumflex
95 _ ASCII: spacing underscore
96 ` ASCII: spacing grave
97 a ASCII: Latin Small Letter A
98 b ASCII: Latin Small Letter B
99 c ASCII: Latin Small Letter C
100 d ASCII: Latin Small Letter D
101 e ASCII: Latin Small Letter E
102 f ASCII: Latin Small Letter F
103 g ASCII: Latin Small Letter G
104 h ASCII: Latin Small Letter H
105 i ASCII: Latin Small Letter I
106 j ASCII: Latin Small Letter J
107 k ASCII: Latin Small Letter K
108 l ASCII: Latin Small Letter L
109 m ASCII: Latin Small Letter M
110 n ASCII: Latin Small Letter N
111 o ASCII: Latin Small Letter O
112 p ASCII: Latin Small Letter P
113 q ASCII: Latin Small Letter Q
114 r ASCII: Latin Small Letter R
115 s ASCII: Latin Small Letter S
116 t ASCII: Latin Small Letter T
117 u ASCII: Latin Small Letter U
118 v ASCII: Latin Small Letter V
119 w ASCII: Latin Small Letter W
120 x ASCII: Latin Small Letter X
121 y ASCII: Latin Small Letter Y
122 z ASCII: Latin Small Letter Z
123 { ASCII: opening curly bracket
124 | ASCII: vertical bar
125 } ASCII: closing curly bracket
126 ~ ASCII: tilde
127  ASCII: DEL (ctrl DELETE)
128 ?
129 �
130 ‚ ASCII: Comma
131 ƒ ASCII: Latin Small Letter F Script
132 „ ASCII: Double Prime Quote Mark Low
133 … ASCII: Ellipsis Low
134 † ASCII: Dagger
135 ‡ ASCII: Double Dagger
136 ˆ ASCII: Circumflex
137 ‰ ASCII: Per Mille (thousand) sign
138 Š ASCII: Latin Capital Letter S Hacek
139 ‹ ASCII: Less-than sign
140 Œ ASCII: Latin Capital Letter OE
141 �
142 Ž
143 �
144 �
145 ‘ ASCII: Opening Single Quotation Mark
146 ’ ASCII: Closing Single Quotation Mark
147 “ ASCII: Opening Double Quotation Mark
148 ” ASCII: Closing Double Quotation Mark
149 • ASCII: Bullet
150 – ASCII: Hyphen or En-dash
151 — ASCII: Em-dash
152 ˜ ASCII: Tilde accent
153 ™ ASCII: Trade Mark sign
154 š ASCII: Latin Small Letter S Hacek
155 › ASCII: Greater-Than sign
156 œ ASCII: Latin Small Letter OE
157 �
158 ž
159 Ÿ ASCII: Latin Capital Letter Y Umlaut
160

161 ¡ ASCII: Latin Small Letter I
162 ¢ ASCII: Cent
163 £ ASCII: Pound Sterling
164 ¤ ASCII: Currency sign
165 ¥ ASCII: Yen
166 ¦ ASCII: Latin Letter Pipe
167 § ASCII: Section sign
168 ¨ ASCII: Umlaut accent
169 © ASCII: Copyright sign
170 ª ASCII: Superscript Small Letter A
171 « ASCII: Left Double-Angle Quotation Mark
172 ¬ ASCII: NOT (Math)
173 ­ ASCII: Hyphen
174 ® ASCII: Registered Name
175 ¯ ASCII: APL Overbar. Macron accent
176 ° ASCII: Ring accent
177 ± ASCII: Plus-Minus sign
178 ² ASCII: Superscript Numeral Two, Squared
179 ³ ASCII: Superscript Numeral Three, Cubed
180 ´ ASCII: Grave accent (?)
181 µ ASCII: Mu or Micro sign
182 ASCII: Paragraph or Pilcrow sign
183 · ASCII: Middle Dot
184 ¸ ASCII: Cedilla Accent
185 ¹ ASCII: Superscript Numeral One
186 º ASCII: Degree, Ring Accent
187 » ASCII: Right Double-Angle Quotation Mark
188 ¼ ASCII: One Quarter
189 ½ ASCII: One Half
190 ¾ ASCII: Three Quarters
191 ¿ ASCII: Turned Question Mark
192 À ASCII: Capital Letter A Grave
193 Á ASCII: Latin Capital Letter A Acute
194 Â ASCII: Latin Capital Letter A Circumflex
195 Ã ASCII: Latin Capital Letter A Tilde
196 Ä ASCII: Latin Capital Letter A Umlaut
197 Å ASCII: Latin Capital Letter A Ring
198 Æ ASCII: Latin Capital Letter AE
199 Ç ASCII: Latin Capital Letter C Cedilla
200 È ASCII: Latin Capital Letter E Grave
201 É ASCII: Latin Capital Letter A Acute
202 Ê ASCII: Latin Capital Letter E Circumflex
203 Ë ASCII: Latin Capital Letter E Umlaut
204 Ì ASCII: Latin Capital Letter I Grave
205 Í ASCII: Latin Capital Letter I Acute
206 Î ASCII: Latin Capital Letter I Circumflex
207 Ï ASCII: Latin Capital Letter I Umlaut
208 Ð ASCII: Latin Capital Letter Eth, D Bar
209 Ñ ASCII: Latin Capital Letter N Tilde
210 Ò ASCII: Latin Capital Letter O Grave
211 Ó ASCII: Latin Capital Letter O Acute
212 Ô ASCII: Latin Capital Letter O Circumflex
213 Õ ASCII: Latin Capital Letter O Tilde
214 Ö ASCII: Latin Capital Letter O Umlaut
215 × ASCII: Multiplication sign
216 Ø ASCII: Greek Letter Phi
217 Ù ASCII: Latin Capital Letter U Grave
218 Ú ASCII: Latin Capital Letter U Acute
219 Û ASCII: Latin Capital Letter U Circumflex
220 Ü ASCII: Latin Capital Letter U Umlaut
221 Ý ASCII: Latin Capital Letter Y Acute
222 Þ ASCII: Latin Small Letter Thorn
223 ß ASCII: Latin Small Letter Sharp S, Ess-Zed
224 à ASCII: Latin Small Letter A Grave
225 á ASCII: Latin Small Letter A Acute
226 â ASCII: Latin Small Letter A Circumflex
227 ã ASCII: Latin Small Letter A Tilde
228 ä ASCII: Latin Small Letter A Umlaut
229 å ASCII: Latin Small Letter A Ring
230 æ ASCII: Latin Small Letter AE
231 ç ASCII: Latin Small Letter C Cedilla
232 è ASCII: Latin Small Letter E Grave
233 é ASCII: Latin Small Letter E Acute
234 ê ASCII: Latin Small Letter E Circumflex
235 ë ASCII: Latin Small Letter E Umlaut
236 ì ASCII: Latin Small Letter I Grave
237 í ASCII: Latin Small Letter I Acute
238 î ASCII: Latin Small Letter I Circumflex
239 ï ASCII: Latin Small Letter I Umlaut
240 ð ASCII: Latin Small Letter Eth
241 ñ ASCII: Latin Small Letter N Tilde
242 ò ASCII: Latin Small Letter O Grave
243 ó ASCII: Latin Small Letter O Acute
244 ô ASCII: Latin Small Letter O Circumflex
245 õ ASCII: Latin Small Letter O Tilde
246 ö ASCII: Latin Small Letter O Umlaut
247 ÷ ASCII: Division sign
248 ø ASCII: Greek Small Letter Phi
249 ù ASCII: Latin Small Letter U Grave
250 ú ASCII: Latin Small Letter U Acute
251 û ASCII: Latin Small Letter U Circumflex
252 ü ASCII: Latin Small Letter U Umlaut
253 ý ASCII: Latin Small Letter Y Acute
254 þ ASCII: Latin Capital Letter Thorn
255 ÿ ASCII: Latin Small Letter Y Umlaut