!636 !standard functions main { psvm { File file = loadDataSnippet("#1000304"); // jar file (1.x MB) System.out.println(file); System.out.println(" " + file.length()); } static File loadDataSnippet(String snippetID) throws IOException { File libraryFile = DiskSnippetCache_getLibrary(parseSnippetID(snippetID)); if (libraryFile == null) { byte[] data = loadDataSnippetImpl(snippetID); DiskSnippetCache_putLibrary(parseSnippetID(snippetID), data); libraryFile = DiskSnippetCache_getLibrary(parseSnippetID(snippetID)); } return libraryFile; } static byte[] loadDataSnippetImpl(String snippetID) throws IOException { byte[] data; try { URL url = new URL("http://eyeocr.sourceforge.net/filestore/filestore.php?cmd=serve&file=blob_" + parseSnippetID(snippetID) + "&contentType=application/binary"); System.err.println("Loading library: " + url); data = loadBinaryPage(url.openConnection()); } catch (FileNotFoundException e) { throw new IOException("Binary snippet #" + snippetID + " not found or not public"); } return data; } public static synchronized File DiskSnippetCache_getLibrary(long snippetID) throws IOException { initSnippetCache(); File file = new File(DiskSnippetCache_dir, "data_" + snippetID + ".jar"); return file.exists() ? file : null; } public static synchronized void DiskSnippetCache_putLibrary(long snippetID, byte[] data) throws IOException { initSnippetCache(); saveBinaryFile(new File(DiskSnippetCache_dir, "data_" + snippetID).getPath() + ".jar", data); } }