Java Code Examples for javax.jnlp.FileContents#getOutputStream()

The following examples show how to use javax.jnlp.FileContents#getOutputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
protected static void saveWindowState(PersistenceService ps, URL codebase, WindowState windowState) {
  try {
    FileContents fc = ps.get(codebase);
    try (XMLEncoder e = new XMLEncoder(new BufferedOutputStream(fc.getOutputStream(true)))) {
      // Test: delete muf ex. C:\Users\(user)\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\muffin\xxxxxx-xxxxx.muf
      // ps.delete(codebase);
      // ObjectOutputStream e = new ObjectOutputStream(fc.getOutputStream(true));
      HashMap<String, Serializable> map = new HashMap<>();
      map.put("size", (Serializable) windowState.getSize());
      map.put("location", (Serializable) windowState.getLocation());
      // Test1: map.put("setting", (Serializable) windowState);
      // Test2: e.writeObject(windowState);
      e.writeObject(map);
      e.flush();
      // e.close();
    }
  } catch (IOException ex) {
    throw new UncheckedIOException(ex);
  }
}
 
Example 2
Source File: WebstartPersistence.java    From marauroa with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets an output stream to this "virtual" file
 * 
 * @param filename
 *            filename (without path)
 * 
 * @return InputStream
 * @throws IOException
 *             on io error
 */
@Override
public OutputStream getOutputStream(boolean relativeToHome, String basedir, String filename)
		throws IOException {
	URL muffinURL = new URL(codebase.toString() + filename);
	try {
		ps.delete(muffinURL);
	} catch (Exception e) {
		// ignore
	}
	ps.create(muffinURL, 5000);
	FileContents fc = ps.get(muffinURL);
	OutputStream os = fc.getOutputStream(false);
	return os;
}