@Override public InputStream openInputFile(String fileName) throws IOException { checkBasics("openInputFile"); URL fileURL = fileNameToURL(fileName); try { return new BufferedInputStream(ps.get(fileURL).getInputStream()); } catch (Exception e) { throw new IOException("openInputFile \"" + fileName + "\" failed", e); } }
/** * Get the current value for this muffin. * @param strParam The key for this muffin parameter. * @return The value for this muffin (null if none). */ public String getMuffin(String strParam) { try { URL url = new URL(m_strCodeBase + strParam); FileContents fc = m_ps.get(url); if (fc == null) return null; // read in the contents of a muffin byte[] buf = new byte[(int)fc.getLength()]; InputStream is = fc.getInputStream(); int pos = 0; while((pos = is.read(buf, pos, buf.length - pos)) > 0) { // just loop } is.close(); String strValue = new String(buf, ENCODING); return strValue; } catch (Exception ex) { // Return null for any exception } return null; } /**
/** * Open this file. * @return */ public InputStream openFileStream(String pathHint, String[] extensions) { if (fos == null) { try { fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); } catch (UnavailableServiceException e) { fos = null; } } if (fos != null) { try { // ask user to select a file through this service FileContents fc = fos.openFileDialog(pathHint, extensions); return fc.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } return null; }
public InputStream openInputFile(String fileName) throws IOException { checkBasics("openInputFile"); URL fileURL = fileNameToURL(fileName); try { return new BufferedInputStream(ps.get(fileURL).getInputStream()); } catch(Exception e) { throw new LSException("openInputFile \"" + fileName + "\" failed", e); } }
URL configURL = new URL(baseURL, fileName); FileContents fc = ps.get(configURL); DataInputStream ois = new DataInputStream(fc.getInputStream());
/** * Loads the file via the JNLP FileOpen service */ public int loadFile(Spreadsheet sheet) { final Controller controller = getController(); try { FileOpenService fos = (FileOpenService) ServiceManager.lookup("javax.jnlp.FileOpenService"); if (fos == null) { return Controller.CANCEL_OPTION; } // ask user to select a file through this service _fc = fos.openFileDialog(null, null); if (_fc == null) return Controller.CANCEL_OPTION; sheet.readSpreadsheet(_fc.getInputStream()); controller.setSheetSource(new URL("file:///"+_fc.getName())); controller.setSheetDirty(false); return Controller.YES_OPTION; } catch (Exception x) { displayError(x); return Controller.CANCEL_OPTION; } }