⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gziptest.java

📁 GZIP为GUN支持的ZIP压缩格式
💻 JAVA
字号:
package example;import javax.microedition.lcdui.*;import javax.microedition.m2g.SVGImage;import javax.microedition.m2g.ScalableGraphics;import javax.microedition.midlet.*; import java.io.*;import javax.microedition.io.Connector;import javax.microedition.io.ContentConnection;import javax.microedition.io.StreamConnection;import javax.microedition.io.HttpConnection;// Import GZIPInputStream classimport com.tinyline.util.GZIPInputStream;/** * GZIPTest is a sample MIDlet that uses GZIPInputStream. */public class GZIPTest extends MIDlet implements Runnable {		/** The example URLs. It is the same SVG content. */		String url = "http://www.tinyline.com/demo/svg/roadmap.svg";		String url2 ="http://www.tinyline.com/demo/svg/roadmap.svgz";		public static final String SVG_IMAGE = "/svg/thumbsUp.svg";		    Gauge gauge;    Form form; 		private Display display; 		private SvgCanvas2 svgCanvas;   /**     * Create the progress form and gauge.     * This program is not interactive, it will exit when done.     */    public GZIPTest() {        gauge = new Gauge("Progress", false, 10, 0);        form = new Form("Progress");        form.append(gauge);        Display.getDisplay(this).setCurrent(form);    }    /**     * Start a thread to run.     */    public void startApp() {        new Thread(this).start();    }    /**     * Run the examples.     */    public void run()		{	     try			 {            gauge.setLabel("Get using ContentConnection");            gauge.setValue(2);	          getViaContentConnection(url);	          //getViaContentConnection(url2);	     }			 catch (Exception e)			 {            System.out.println(e);            e.printStackTrace();       }       gauge.setValue(10);       notifyDestroyed();		}    public void pauseApp()		{    }    /**     * Destroy must cleanup everything.  The thread is signaled     * to stop and no result is produced.     * @param unconditional true if forced shutdown.     */    public void destroyApp(boolean unconditional) {    }    void getViaContentConnection(String url) throws IOException    {        ContentConnection c = null;        InputStream is = null;				GZIPInputStream gis = null;        byte[] buf = new byte[512];        int len;        try        {           c = (ContentConnection)Connector.open(url);           is = c.openInputStream();					 // If the url ends with svgz then use the					 // GZIPInputStream           if(url.endsWith("svgz"))           {							// Open the GZIPInputStream the regular way              is = new GZIPInputStream(is);           }           long t0,t1;                  // time stamps           t0 = System.currentTimeMillis();					 //Read the gzip archive.           //while ((len = is.read(buf)) >= 0)					 {							 // Print the content if you want							 //System.out.println(""+ new String(buf));           }                      //while ((len = is.read(buf)) >= 0)					 {							 // Print the content if you want							 //System.out.println(""+ new String(buf));           }           t1 = System.currentTimeMillis();           System.out.println(url+ " elapsed time: " + (t1-t0));                      InputStream svgDemoStream = getClass().getResourceAsStream(SVG_IMAGE);                      svgCanvas = new SvgCanvas2 (false,svgDemoStream);                      //svgCanvas = new SvgCanvas2 (false,is);        	//svgCanvas.setCommandListener(this);        					// *** grab a reference to the display        	display = Display.getDisplay(this);        	display.setCurrent(svgCanvas);        }        finally        {           if (is != null)           is.close();           if (c != null)           c.close();        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -