public static void copyToFile(InputStream is, File dst) throws IOException { FileOutputStream fos = null; try { fos = new FileOutputStream(dst); byte[] buf = new byte[1024]; int i = 0; while ((i = is.read(buf)) != -1) { fos.write(buf, 0, i); } } finally { closeQuietly(fos); } }
public static String getCanonicalFileClassLoaderURL(File file) { String url = getCanonicalFileURL(file); if ((file.isDirectory()) && (!url.endsWith("/"))) { url += "/"; } return url; }
IOUtils.copyToFile(is, tmp); return IOUtils.getCanonicalFileClassLoaderURL(tmp); } catch (IOException e) { if (reportError) { IOUtils.closeQuietly(is);
public static void copyFile(File src, File dst) throws IOException { FileInputStream fis = null; try { fis = new FileInputStream(src); copyToFile(fis, dst); } finally { closeQuietly(fis); } }
public void configure(MIDletClassLoaderConfig clConfig, boolean forJad) throws MalformedURLException { for (Iterator iter = clConfig.appclasspath.iterator(); iter.hasNext();) { String path = (String) iter.next(); StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { this.addURL(new URL(IOUtils.getCanonicalFileClassLoaderURL(new File(st.nextToken())))); } } for (Iterator iter = clConfig.appclasses.iterator(); iter.hasNext();) { this.addClassURL((String) iter.next()); } int delegationType = clConfig.getDelegationType(forJad); this.delegatingToParent = (delegationType == MIDletClassLoaderConfig.DELEGATION_DELEGATING); this.findPathInParent = (delegationType == MIDletClassLoaderConfig.DELEGATION_RELAXED); }
deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath()); IOUtils.copyFile(fileChooser.getSelectedFile(), deviceFile);
private static void saveDevice(XMLElement doc) { File configFile = new File(".", "device-tmp.xml"); FileWriter fw = null; try { fw = new FileWriter(configFile); doc.write(fw); fw.close(); } catch (IOException ex) { System.out.println(ex); } finally { IOUtils.closeQuietly(fw); } }
public void addClasspath(String classpath) { StringTokenizer st = new StringTokenizer(classpath, ";"); while (st.hasMoreTokens()) { try { String path = st.nextToken(); if (path.startsWith("file:")) { addURL(new URL(path)); } else { addURL(new URL(IOUtils.getCanonicalFileURL(new File(path)))); } } catch (MalformedURLException e) { throw new Error(e); } } }
.getClassName(), midletOutputFile, appletPackageOutputFile, deviceOutputFile); AppletProducer.createMidlet(new URL(midletInput), midletOutputFile); IOUtils.copyFile(appletJarFile, appletPackageOutputFile); if (deviceInput != null && deviceInput.getFileName() != null) { IOUtils.copyFile(new File(Config.getConfigPath(), deviceInput.getFileName()), deviceOutputFile);
IOUtils.closeQuietly(buildVersionInputStream); IOUtils.closeQuietly(mavenDataInputStream);
public void actionPerformed(ActionEvent ev) { if (fileChooser == null) { ExtensionFileFilter fileFilter = new ExtensionFileFilter("MIDlet files"); fileFilter.addExtension("jad"); fileFilter.addExtension("jar"); fileChooser = new JFileChooser(); fileChooser.setFileFilter(fileFilter); fileChooser.setDialogTitle("Open MIDlet File..."); fileChooser.setCurrentDirectory(new File(Config.getRecentDirectory("recentJadDirectory"))); } int returnVal = fileChooser.showOpenDialog(Main.this); if (returnVal == JFileChooser.APPROVE_OPTION) { Config.setRecentDirectory("recentJadDirectory", fileChooser.getCurrentDirectory().getAbsolutePath()); String url = IOUtils.getCanonicalFileURL(fileChooser.getSelectedFile()); Common.openMIDletUrlSafe(url); if (recordStoreManagerDialog != null) { recordStoreManagerDialog.refresh(); } } } };
deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath()); IOUtils.copyFile(file, deviceFile);
private Image getImage(String str) throws IOException { // TODO not always true, there could be some loading images before // invoke startApp, right now getCurrentMIDlet returns prevoius MIDlet Object midlet = MIDletBridge.getCurrentMIDlet(); if (midlet == null) { midlet = getClass(); } InputStream is = midlet.getClass().getResourceAsStream(str); if (is == null) { throw new IOException(str + " could not be found."); } try { return getImage(is); } finally { IOUtils.closeQuietly(is); } }
File file = new File((String) argsIterator.next()); argsIterator.remove(); propertiesJad = file.exists() ? IOUtils.getCanonicalFileURL(file) : arg; } else if (arg.equals("--appclassloader")) { if (clConfig == null) {
File src = new File(getConfigPath(), entry.getFileName()); File dst = File.createTempFile("dev", ".jar", getConfigPath()); IOUtils.copyFile(src, dst); entry.setFileName(dst.getName()); addDeviceEntry(entry);
} catch (Throwable ignore) { } finally { IOUtils.closeQuietly(out);
public void handleEvent(Event ev) { if (fileDialog == null) { fileDialog = new FileDialog(shell, SWT.OPEN); fileDialog.setText("Open JAD File..."); fileDialog.setFilterNames(new String[] {"JAD files"}); fileDialog.setFilterExtensions(new String[] {"*.jad"}); fileDialog.setFilterPath(Config.getRecentDirectory("recentJadDirectory")); } fileDialog.open(); if (fileDialog.getFileName().length() > 0) { File selectedFile; if (fileDialog.getFilterPath() == null) { selectedFile = new File(fileDialog.getFileName()); } else { selectedFile = new File(fileDialog.getFilterPath(), fileDialog.getFileName()); Config.setRecentDirectory("recentJadDirectory", fileDialog.getFilterPath()); } String url = IOUtils.getCanonicalFileURL(selectedFile); Common.openJadUrlSafe(url); } } };
private Image getImage(String str) throws IOException { // TODO not always true, there could be some loading images before // invoke startApp, right now getCurrentMIDlet returns prevoius MIDlet Object midlet = MIDletBridge.getCurrentMIDlet(); if (midlet == null) { midlet = getClass(); } InputStream is = midlet.getClass().getResourceAsStream(str); if (is == null) { throw new IOException(str + " could not be found."); } try { return getImage(is); } finally { IOUtils.closeQuietly(is); } }
File f = (File) fileList.get(0); if (Common.isMIDletUrlExtension(f.getName())) { Common.openMIDletUrlSafe(IOUtils.getCanonicalFileURL(f)); } else { Message.warn("Unable to open " + f.getAbsolutePath() + ", Only JAD files are acepted");