List of usage examples for java.io ObjectInputStream readInt
public int readInt() throws IOException
From source file:ti.modules.titanium.network.TiCookieStore.java
private Cookie decodeCookie(String cookieString) { byte[] cookieBytes = hexStringToByteArray(cookieString); ByteArrayInputStream inputStream = new ByteArrayInputStream(cookieBytes); BasicClientCookie cookie = null;/*w w w. j ava2 s . co m*/ try { ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); String name = (String) objectInputStream.readObject(); String value = (String) objectInputStream.readObject(); cookie = new BasicClientCookie(name, value); cookie.setComment((String) objectInputStream.readObject()); cookie.setDomain((String) objectInputStream.readObject()); cookie.setVersion(objectInputStream.readInt()); cookie.setSecure(objectInputStream.readBoolean()); cookie.setExpiryDate((Date) objectInputStream.readObject()); cookie.setPath((String) objectInputStream.readObject()); } catch (Exception e) { Log.w(TAG, "Failed to decode cookie", Log.DEBUG_MODE); return null; } return cookie; }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mission_planner); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_mission_planner); if (savedInstanceState == null) { // Load saved missionData if available. try {//from ww w. j ava2s .c om FileInputStream inStream = new FileInputStream( Environment.getExternalStorageDirectory() + File.separator + "MissionData"); ObjectInputStream objectInStream = new ObjectInputStream(inStream); int count = objectInStream.readInt(); for (int i = 0; i < count; i++) missionData.add((MissionData) objectInStream.readObject()); objectInStream.close(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the list is empty, add the default planet if (missionData.size() == 0) { missionData = setFirstMissionData(); } } else { missionData = savedInstanceState.getParcelableArrayList("key"); } mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground); mListView = (ListView) findViewById(R.id.list); tvTotalDeltaV = (TextView) findViewById(R.id.tvTotalDeltaV); mAdapter = new StableArrayAdapter(this, missionData, mTouchListener); // add the newDestination button as a footer below the listview ImageView newDestination = new ImageView(this); newDestination.setImageResource(R.drawable.ic_plus); mListView.addFooterView(newDestination); newDestination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int possibleIconState = 0; // Lets MissionDestination know which icons it's allowed to use if (missionData.size() < 1) { possibleIconState = 1; } Intent intent = new Intent(MissionPlanner.this, MissionDestination.class); intent.putExtra("possibleIconState", possibleIconState); intent.putExtra("isNewItem", true); // Places the result as a new item in the listview startActivityForResult(intent, 0); } }); mListView.setAdapter(mAdapter); }
From source file:org.protempa.CompoundLowLevelAbstractionDefinition.java
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject();//from ww w . ja v a 2 s . c o m if (this.minimumNumberOfValues < 1) { throw new InvalidObjectException("minimumNumberOfValues must be > 0"); } initInstance(); int numValueClassifications = s.readInt(); for (int i = 0; i < numValueClassifications; i++) { ValueClassification vc = (ValueClassification) s.readObject(); if (vc != null) { addValueClassification(vc); } else { throw new InvalidObjectException("null ValueClassification"); } } }
From source file:org.datanucleus.store.hbase.fieldmanager.FetchFieldManager.java
private int fetchIntInternal(AbstractMemberMetaData mmd, byte[] bytes) { int value;/*from w ww. j av a 2s . c om*/ if (bytes == null) { // Handle missing field String dflt = HBaseUtils.getDefaultValueForMember(mmd); if (dflt != null) { return Integer.valueOf(dflt).intValue(); } return 0; } if (mmd.isSerialized()) { try { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis); value = ois.readInt(); ois.close(); bis.close(); } catch (IOException e) { throw new NucleusException(e.getMessage(), e); } } else { value = Bytes.toInt(bytes); } return value; }
From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java
private boolean readState() { ObjectInputStream ois = null; try {// w w w. ja v a 2 s. c om ois = new ObjectInputStream(new FileInputStream("jFunkFrame.state")); setBounds((Rectangle) ois.readObject()); setExtendedState(ois.readInt()); tree.setSelectionPaths((TreePath[]) ois.readObject()); jFunkPropertyFilesComboBox.setSelectedIndex(ois.readInt()); testSystemsComboBox.setSelectedIndex(ois.readInt()); mailConfigurationsComboBox.setSelectedIndex(ois.readInt()); threadCountComboBox.setSelectedIndex(ois.readInt()); parallelComboBox.setSelectedIndex(ois.readInt()); return true; } catch (final FileNotFoundException ex) { log.warn("Could not find saved state (which is fine during first start)"); return false; } catch (final Exception ex) { log.error("Error reading state", ex); return false; } finally { IOUtils.closeQuietly(ois); } }
From source file:org.nuxeo.ecm.core.api.SerializableInputStream.java
private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { // always perform the default de-serialization first in.defaultReadObject();//w ww . j a va 2 s. c o m // create a temp file where we will put the blob content file = Framework.createTempFile("SerializableIS-", ".tmp"); Framework.trackFile(file, file); OutputStream out = null; try { out = new FileOutputStream(file); byte[] buffer = new byte[IN_MEM_LIMIT]; int read; int bytes = in.readInt(); while (bytes > -1 && (read = in.read(buffer, 0, bytes)) != -1) { out.write(buffer, 0, read); bytes -= read; if (bytes == 0) { bytes = in.readInt(); } } } finally { if (out != null) { out.close(); } if (file.isFile()) { this.in = new BufferedInputStream(new FileInputStream(file)); } } }
From source file:org.spout.api.inventory.ItemStack.java
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { short matId = in.readShort(); short matData = in.readShort(); material = MaterialRegistry.get(matId); if (matData != 0 && material != null) { material = material.getSubMaterial(matData); }// w w w . j a v a 2 s .c om amount = in.readInt(); data = in.readShort(); int auxDataSize = in.readInt(); if (auxDataSize > 0) { byte[] auxData = new byte[auxDataSize]; ManagedHashMap map = new ManagedHashMap(); map.deserialize(auxData); this.auxData = map; } boolean hasNBTData = in.readBoolean(); if (hasNBTData) { NBTInputStream is = new NBTInputStream(in, false); CompoundTag tag = (CompoundTag) is.readTag(); nbtData = tag.getValue(); is.close(); } if (material == null) { throw new ClassNotFoundException("No material matching {" + matId + ", " + matData + "} was found!"); } }
From source file:idontwant2see.IDontWant2See.java
public void readData(final ObjectInputStream in) throws IOException, ClassNotFoundException { final int version = in.readInt(); // read Version int n = in.readInt(); if (version <= 2) { for (int i = 0; i < n; i++) { final StringBuilder value = new StringBuilder("*"); value.append(in.readUTF()).append("*"); mSettings.getSearchList().add(new IDontWant2SeeListEntry(value.toString(), false)); }/*from w ww.ja v a 2s . c o m*/ if (version == 2) { n = in.readInt(); for (int i = 0; i < n; i++) { mSettings.getSearchList().add(new IDontWant2SeeListEntry(in.readUTF(), true)); } mSettings.setSimpleMenu(false); } } else { for (int i = 0; i < n; i++) { mSettings.getSearchList().add(new IDontWant2SeeListEntry(in, version)); } mSettings.setSimpleMenu(in.readBoolean()); if (version >= 4) { mSettings.setSwitchToMyFilter(in.readBoolean()); } if (version >= 5) { mSettings.setLastEnteredExclusionString(in.readUTF()); } if (version >= 6) { mSettings.setLastUsedDate(Date.readData(in)); } if (version >= 7) { mSettings.setProgramImportance(in.readByte()); } else { mSettings.setProgramImportance(Program.DEFAULT_PROGRAM_IMPORTANCE); } } }
From source file:org.photovault.replication.Change.java
private void readFieldChanges(ObjectInputStream s) throws IOException, ClassNotFoundException { int count = s.readInt(); changedFields = new HashMap<String, FieldChange>(); for (int n = 0; n < count; n++) { String field = (String) s.readObject(); FieldChange val = (FieldChange) s.readObject(); changedFields.put(field, val); }//from w w w. j a va 2s.co m }
From source file:it.scoppelletti.programmerpower.web.control.ActionBase.java
/** * Deserializza l’oggetto.//from www.j a v a 2s .com * * @param in Flusso di lettura. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int i, n; in.defaultReadObject(); myMessages = new ArrayList<ActionMessage>(); n = in.readInt(); for (i = 0; i < n; n++) { myMessages.add((ActionMessage) in.readObject()); } }