FileDocCategorySizeDatePackage
Support_GetLocal.javaAPI DocAndroid 1.5 API3658Wed May 06 22:41:06 BST 2009tests.support

Support_GetLocal

public class Support_GetLocal extends Object

Fields Summary
static Hashtable
cache
Constructors Summary
Methods Summary
public static java.io.FilecreateTempFile(java.lang.String suffix)

        return File.createTempFile("hyts_", suffix, null);
    
public static java.io.FilegetExternalLocalFile(java.lang.String url)

        File temp = cache.get(url);
        if (temp == null) {
            InputStream in = new URL(url).openStream();
            temp = File.createTempFile("hyts_local", ".tmp", null);
            temp.deleteOnExit();
            FileOutputStream out = new FileOutputStream(temp);
            int result;
            byte[] buf = new byte[4096];
            while ((result = in.read(buf)) != -1) {
                out.write(buf, 0, result);
            }
            in.close();
            out.close();
            cache.put(url, temp);
        }
        return temp;
    
public static java.net.JarURLConnectiongetJarURLConnection()

        JarURLConnection con1 = null;
        File file = getLocalFile("hyts_att.jar");
        URL fUrl1 = new URL("jar:file:" + file.getPath() + "!/");
        con1 = (JarURLConnection) fUrl1.openConnection();
        return con1;
    
public static java.io.FilegetLocalFile(java.lang.String url)


          
             
        url = Support_Resources.RESOURCE_PACKAGE + url;
        File temp = cache.get(url);
        if (temp == null) {
            InputStream in = Support_GetLocal.class.getResourceAsStream(url);
            temp = File.createTempFile("hyts_local", ".tmp", null);
            temp.deleteOnExit();
            FileOutputStream out = new FileOutputStream(temp);
            int result;
            byte[] buf = new byte[4096];
            while ((result = in.read(buf)) != -1) {
                out.write(buf, 0, result);
            }
            in.close();
            out.close();
            cache.put(url, temp);
        }
        return temp;
    
static java.io.ByteArrayInputStreamgetStream(java.lang.String url)

        InputStream in = new URL(url).openStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream(256);
        int result;
        byte[] buf = new byte[256];
        while ((result = in.read(buf)) != -1) {
            out.write(buf, 0, result);
        }
        return new ByteArrayInputStream(out.toByteArray());