Codota Logo
IOUtils
Code IndexAdd Codota to your IDE (free)

How to use
IOUtils
in
org.microemu.app.util

Best Java code snippets using org.microemu.app.util.IOUtils (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: org.microemu/microemu-javase

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);	
  }
}

origin: org.microemu/microemu-javase

public static String getCanonicalFileClassLoaderURL(File file) {
  String url = getCanonicalFileURL(file);
  if ((file.isDirectory()) && (!url.endsWith("/"))) {
    url += "/";
  }
  return url;
}

origin: org.microemu/microemu-javase

  IOUtils.copyToFile(is, tmp);
  return IOUtils.getCanonicalFileClassLoaderURL(tmp);
} catch (IOException e) {
  if (reportError) {
  IOUtils.closeQuietly(is);
origin: org.microemu/microemu-javase

public static void copyFile(File src, File dst) throws IOException {
  FileInputStream fis = null;
  try {
    fis = new FileInputStream(src);
    copyToFile(fis, dst);
  } finally {
    closeQuietly(fis); 
  }
}

origin: org.microemu/microemu-javase-swing

  IOUtils.copyFile(appletInputFile, appletOutputFile);
  IOUtils.copyFile(deviceInputFile, deviceOutputFile);
} catch (IOException ex) {
  ex.printStackTrace();
origin: org.microemu/microemu-javase

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);
}
origin: org.microemu/microemu-javase-swing

  deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath());
IOUtils.copyFile(fileChooser.getSelectedFile(), deviceFile);
origin: org.microemu/microemu-javase

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);
  }
}
origin: org.microemu/microemu-javase

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);
    }
  }
}
 
origin: org.microemu/microemu-javase-swing

    .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);
origin: org.microemu/microemu-javase

IOUtils.closeQuietly(buildVersionInputStream);
IOUtils.closeQuietly(mavenDataInputStream);
origin: org.microemu/microemu-javase-swing

  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();
      }
    }
  }
};
origin: org.microemu/microemu-javase-swt

  deviceFile = File.createTempFile("device", ".jar", Config.getConfigPath()); 
IOUtils.copyFile(file, deviceFile);
origin: org.microemu/microemu-javase-swing

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);
  }
}
origin: org.microemu/microemu-javase

  File file = new File((String) argsIterator.next());
  argsIterator.remove();
  propertiesJad = file.exists() ? IOUtils.getCanonicalFileURL(file) : arg;
} else if (arg.equals("--appclassloader")) {
  if (clConfig == null) {
origin: org.microemu/microemu-javase

File src = new File(getConfigPath(), entry.getFileName());
File dst = File.createTempFile("dev", ".jar", getConfigPath());
IOUtils.copyFile(src, dst);
entry.setFileName(dst.getName());
addDeviceEntry(entry);
origin: org.microemu/microemu-javase

} catch (Throwable ignore) {
} finally {
  IOUtils.closeQuietly(out);
origin: org.microemu/microemu-javase-swt

  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);
    }
  } 
};
origin: org.microemu/microemu-javase-swt

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);
  }
}
origin: org.microemu/microemu-javase-swing

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");	
org.microemu.app.utilIOUtils

Javadoc

General IO stream manipulation utilities. Some functions are based on org.apache.commons.io

This class provides static utility methods for input/output operations.

  • closeQuietly - these methods close a stream ignoring nulls and exceptions

Most used methods

  • closeQuietly
    Unconditionally close a Writer. Equivalent to Writer#close(), except any exceptions will be ignored.
  • copyFile
  • getCanonicalFileURL
    Solution for JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6351751
  • copyToFile
  • getCanonicalFileClassLoaderURL

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • Path (java.nio.file)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now