public void readBytes(InputStream in) throws DataFormatException, IOException { _reason = DataHelper.readString(in); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _reason = DataHelper.readString(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { if (size > 0) { try { _version = DataHelper.readString(in); if (size > 1 + _version.length()) // assume ascii _options = DataHelper.readProperties(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Bad version string", dfe); } } }
/** * As of 0.9.3, expiration MUST be all zeros as it is ignored on * readin and the signature will fail. * Restored as of 0.9.12, wait several more releases before using. * @throws IllegalStateException if was already read in */ public void readBytes(InputStream in) throws DataFormatException, IOException { if (_transportStyle != null) throw new IllegalStateException(); // EOF will be thrown in next read _cost = (short) in.read(); _expiration = DataHelper.readLong(in, 8); _transportStyle = DataHelper.readString(in); // reduce Object proliferation if (_transportStyle.equals("SSU")) _transportStyle = "SSU"; else if (_transportStyle.equals("NTCP")) _transportStyle = "NTCP"; else if (_transportStyle.equals("NTCP2")) _transportStyle = "NTCP2"; DataHelper.readProperties(in, _options); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _date = DataHelper.readDate(in); if (size > DataHelper.DATE_LENGTH) _version = DataHelper.readString(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
String key = DataHelper.readString(in); int b = in.read(); if (b != '=')
ByteArrayInputStream in = new ByteArrayInputStream(data); while (in.available() > 0) { String key = readString(in); String cached = _propertiesKeyCache.get(key); if (cached != null) if (b != '=') throw new DataFormatException("Bad key"); String val = readString(in); b = in.read(); if (b != ';')
String key; try { key = readString(in); String cached = _propertiesKeyCache.get(key); if (cached != null) val = readString(in); int b = in.read(); if (b != ';')
@Test public void testString() throws Exception{ byte[] temp = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataHelper.writeString(baos, "Hello, I2P"); temp = baos.toByteArray(); String s = null; ByteArrayInputStream bais = new ByteArrayInputStream(temp); s = DataHelper.readString(bais); assertEquals(s, "Hello, I2P"); }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _reqID = DataHelper.readLong(in, 4); _timeout = DataHelper.readLong(in, 4); _lookupType = (int) DataHelper.readLong(in, 1); if (_lookupType == LOOKUP_HASH) { _hash = Hash.create(in); } else if (_lookupType == LOOKUP_HOST) { _host = DataHelper.readString(in); if (_host.length() == 0) throw new I2CPMessageException("bad host"); } else { throw new I2CPMessageException("bad type"); } } catch (DataFormatException dfe) { throw new I2CPMessageException("bad data", dfe); } }