Reading Javadocs from inside the original zip file
Pubblicato da Luigi il 19 Novembre 2006 in JavaJDK 1.5 Javadocs zip file is 45MB compressed, and 235MB uncompressed. If you’d like to browse its content without uncompress it, you can use following servlet:
1public class JavadocSampleServlet extends HttpServlet { 2 private static final String JAVADOC_LOCATION = 3 "D:/Java/docs/jdk-1_5_0-doc.zip"; 4 protected void doGet(HttpServletRequest req, HttpServletResponse res) 5 throws ServletException, IOException { 6 String resource = req.getPathInfo(); 7 if (resource == null || "/".equals(resource)) 8 resource = "/index.html"; 9 URL url = new URL("jar:file:///" + JAVADOC_LOCATION + 10 "!/docs" + resource); 11 URLConnection conn = url.openConnection(); 12 InputStream input = null; 13 OutputStream output = null; 14 try { 15 input = conn.getInputStream(); 16 output = res.getOutputStream(); 17 int c; 18 while ((c = input.read()) != -1) output.write(c); 19 output.flush(); 20 } finally { 21 if (input != null) input.close(); 22 if (output != null) output.close(); 23 } 24 } 25}
Set up the constant JAVADOC_LOCATION with proper javadoc file path on your disk.
Here’s the servlet mapping:
1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> 3<web-app> 4 <servlet> 5 <servlet-name>javadoc</servlet-name> 6 <servlet-class> 7 it.newinstance.sample.JavadocSampleServlet 8 </servlet-class> 9 </servlet> 10 <servlet-mapping> 11 <servlet-name>javadoc</servlet-name> 12 <url-pattern>/javadoc/*</url-pattern> 13 </servlet-mapping> 14</web-app>
Configure it in your tomcat and go for the URL:
http://localhost:8080/${yourContextName}/javadoc/
and enjoy.
You’ve saved 190MB of disk space
Notice the new feature of colored sources on my blog: I used this post to test if it works correctly. This weekend I wrote my parser to convert java sources to html. Seems good, isn’t that?
2 Commenti a “Reading Javadocs from inside the original zip file”
Lascia un Commento
Cerca
Calendario
| L | M | M | G | V | S | D |
|---|---|---|---|---|---|---|
| « Ott | Dic » | |||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
Archivi
- Gennaio 2010 (2)
- Dicembre 2009 (1)
- Novembre 2009 (3)
- Settembre 2009 (2)
- Agosto 2009 (4)
- Luglio 2009 (1)
- Giugno 2009 (2)
- Maggio 2009 (4)
- Aprile 2009 (2)
- Marzo 2009 (7)
- Febbraio 2009 (5)
- Gennaio 2009 (2)
- Dicembre 2008 (1)
- Novembre 2008 (8)
- Ottobre 2008 (12)
- Settembre 2008 (3)
- Agosto 2008 (2)
- Luglio 2008 (6)
- Giugno 2008 (16)
- Maggio 2008 (2)
- Aprile 2008 (3)
- Marzo 2008 (6)
- Ottobre 2007 (1)
- Settembre 2007 (1)
- Agosto 2007 (5)
- Luglio 2007 (6)
- Giugno 2007 (6)
- Maggio 2007 (1)
- Marzo 2007 (1)
- Febbraio 2007 (2)
- Gennaio 2007 (1)
- Dicembre 2006 (2)
- Novembre 2006 (4)
- Ottobre 2006 (7)
- Settembre 2006 (1)
- Agosto 2006 (2)
- Luglio 2006 (6)
- Giugno 2006 (3)
- Febbraio 2006 (1)
- Gennaio 2006 (1)
- Dicembre 2005 (5)
- Novembre 2005 (2)
- Ottobre 2005 (2)
- Settembre 2005 (7)
- Agosto 2005 (2)
- Luglio 2005 (8)
- Giugno 2005 (12)
Categorie
- Books (7)
- Eclipse (10)
- Errors (2)
- Firefox (7)
- Hardware (14)
- Horror Code (8)
- Internet (17)
- Java (85)
- JavaScript (8)
- Life, universe and everything (29)
- Linux (44)
- Mac (18)
- Software (25)
- Speeches and Conferences (8)
- Web (19)
- Windows (16)
Ultimi Post
- Syntactic sugar and Java arrays.
- 3G USB Stick on Ubuntu
- Ipod touch with Linux
- Karmic and Luks: USB drive encryption made (almost) easy
- Suspend/Resume in Karmic /2
- Suspend/Resume problem in Ubuntu Karmic 9.10 running on MacBook Pro 5.1
- MacBook International Keyboard and Linux
- Mighty Mouse: reverse horizontal scrolling workaround on Ubuntu Linux 9.04
- Skype 2.1.0.47 beta released, and amd64 packages available!
- Linux RAM Disks
My open source projects
Blog License
Blogs I like
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Filippo Diotalevi
- JavaJournal.it Blog
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links








Or you could try ClassFinder.
It is open source and serves docs and source (and on-the-fly decompiles) with a very small code base.
It has been developed a couple of years ago, but I still haven’t found anything to beat it.
Perché non facciamo un sito per il browse di codice sorgente?????