List of usage examples for java.io ObjectOutputStream writeInt
public void writeInt(int val) throws IOException
From source file:org.spout.api.inventory.ItemStack.java
private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.writeShort(material.getId());//from w w w . j ava 2s . c om out.writeShort(material.getData()); out.writeInt(amount); out.writeShort(data); byte[] auxData = this.auxData.serialize(); if (auxData != null) { out.writeInt(auxData.length); out.write(auxData); } else { out.writeInt(0); } if (nbtData != null && !nbtData.isEmpty()) { out.writeBoolean(true); NBTOutputStream os = new NBTOutputStream(out, false); os.writeTag(new CompoundTag("nbtData", nbtData)); os.close(); } else { out.writeBoolean(false); } }
From source file:org.nuxeo.ecm.core.api.SerializableInputStream.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject();//from ww w . j a v a 2 s. c om // write content if (in == null) { return; } try { int read; byte[] buf = new byte[IN_MEM_LIMIT]; while ((read = in.read(buf)) != -1) { // next follows a chunk of 'read' bytes out.writeInt(read); out.write(buf, 0, read); } out.writeInt(-1); // EOF } finally { if (in != null) { in.close(); } } }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override public void onPause() { super.onPause(); try {/*from w w w . j a va 2s. c om*/ File file = new File(Environment.getExternalStorageDirectory() + File.separator + "MissionData"); file.createNewFile(); FileOutputStream outStream = new FileOutputStream(file); ObjectOutputStream objectOutStream = new ObjectOutputStream(outStream); objectOutStream.writeInt(missionData.size()); for (MissionData r : missionData) objectOutStream.writeObject(r); objectOutStream.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.izforge.izpack.compiler.packager.impl.MultiVolumePackager.java
/** * Writes a pack./*from w w w. j a va2s . c o m*/ * <p/> * Pack information is written to the installer jar, while the actual files are written to the volumes. * * @param packInfo the pack information * @param volumes the volumes * @param targetDir the target directory for loosefiles * @throws IOException for any I/O error */ private void writePack(PackInfo packInfo, FileSpanningOutputStream volumes, File targetDir) throws IOException { Pack pack = packInfo.getPack(); pack.setFileSize(0); String name = pack.getName(); sendMsg("Writing Pack: " + name, PackagerListener.MSG_VERBOSE); logger.fine("Writing Pack: " + name); ZipEntry entry = new ZipEntry(RESOURCES_PATH + "packs/pack-" + name); JarOutputStream installerJar = getInstallerJar(); installerJar.putNextEntry(entry); ObjectOutputStream packStream = new ObjectOutputStream(installerJar); writePackFiles(packInfo, volumes, pack, packStream, targetDir); // Write out information about parsable files packStream.writeInt(packInfo.getParsables().size()); for (ParsableFile file : packInfo.getParsables()) { packStream.writeObject(file); } // Write out information about executable files packStream.writeInt(packInfo.getExecutables().size()); for (ExecutableFile file : packInfo.getExecutables()) { packStream.writeObject(file); } // Write out information about update check files packStream.writeInt(packInfo.getUpdateChecks().size()); for (UpdateCheck check : packInfo.getUpdateChecks()) { packStream.writeObject(check); } // Cleanup packStream.flush(); }
From source file:org.opendas.calendar.Settings.java
/** * Save the sync settings/*w w w .j a v a2 s. c o m*/ * * @param prot * protocol type * @param user * user name * @param pw * password * @param ftp_hpath * ftp: host and path * @param fs_path * noftp: host and path */ public void save_sync_settings(int prot, String user, String pw, String ftp_hpath, String fs_path) { protocol = prot; user_name = user; password = pw; ftp_host_path_name = ftp_hpath; path_name = fs_path; try { new File(sync_settings_file_name).delete(); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sync_settings_file_name)); out.writeInt(prot); out.writeObject(encode_Base64(user)); out.writeObject(encode_Base64(pw)); out.writeObject(ftp_hpath); out.writeObject(fs_path); out.close(); } catch (Exception b) { b.printStackTrace(); } }
From source file:de.flyingsnail.ipv6droid.android.MainActivity.java
/** Write to a private file. Format is: ArrayList<TicTunnel> tunnels; int selected */ private void writePersistedTunnel(TicTunnel tunnel) { try {/* ww w . ja va 2 s . c om*/ OutputStream fs = openFileOutput(FILE_LAST_TUNNEL, MODE_PRIVATE); ObjectOutputStream os = new ObjectOutputStream(fs); List<TicTunnel> tunnelList = new ArrayList<TicTunnel>(1); tunnelList.add(tunnel); os.writeObject(tunnelList); os.writeInt(0); os.close(); fs.close(); } catch (IOException e) { Log.e(TAG, "Could not write last working tunnel to preferences", e); } }
From source file:org.opendas.calendar.Settings.java
/** * Save GUI settings/*from w ww . j a v a 2 s . c o m*/ * * @param x * x position of main frame on screen * @param y * y position of main frame on screen * @param width * main frame width * @param sh * slot height * @param dh * main frame decoration height * @param nor_hours * number of rendered hours * @param eview * false - simple view, true - extended view<br> * @param rl * false - don't show row labels, true - show it<br> * */ public void save_gui_settings(int x, int y, int width, int sh, int dh, long nor_hours, boolean eview, boolean rl) { frame_x = x; frame_y = y; frame_width = width; slot_height = sh; decor_height = dh; number_of_rendered_hours = nor_hours; ext_view = eview; show_row_labels = rl; try { new File(gui_settings_file_name).delete(); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(gui_settings_file_name)); out.writeInt(x); out.writeInt(y); out.writeInt(width); out.writeInt(sh); out.writeInt(dh); out.writeLong(nor_hours); out.writeBoolean(eview); out.writeBoolean(rl); out.close(); } catch (Exception b) { b.printStackTrace(); } }
From source file:com.projity.pm.task.TaskSnapshot.java
public void serialize(ObjectOutputStream s) throws IOException { currentSchedule.serialize(s);/*from w w w.j av a 2 s . co m*/ //s.writeObject(hasAssignments); s.writeDouble(fixedCost); s.writeInt(fixedCostAccrual); s.writeBoolean(ignoreResourceCalendar); s.writeInt(hasAssignments.getSchedulingType()); s.writeBoolean(hasAssignments.isEffortDriven()); }
From source file:com.lillicoder.newsblurry.net.SerializableCookie.java
/** * * Serialization methods./*from w w w . j a va 2 s . co m*/ * */ private void writeObject(ObjectOutputStream out) throws IOException { Cookie cookie = this.getCookie(); // Write all values that can later be restored. // This means excluding comment URL, persistence value, // and ports. out.writeObject(cookie.getComment()); out.writeObject(cookie.getDomain()); out.writeObject(cookie.getExpiryDate()); out.writeObject(cookie.getName()); out.writeObject(cookie.getPath()); out.writeObject(cookie.getValue()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.isSecure()); }
From source file:org.opendas.calendar.Settings.java
/** * Save row labels and number of slots.<br> * (number of displayed rows = number of slots - 5) * // ww w. j a v a 2s . c o m * @param ns * number of slots for calendar und dates in simple view */ public void save_row_settings(int ns) { number_of_slots = ns; try { new File(row_settings_file_name).delete(); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(row_settings_file_name)); out.writeObject(row_label); out.writeInt(ns); out.close(); } catch (Exception b) { b.printStackTrace(); } }