bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.ENCODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.ENCODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
InputStream stream = new Base64.InputStream(binary.getStream(), Base64.ENCODE); try { while (-1 != (len = stream.read(bytes))) {
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.ENCODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes; if (bis != null) bis.close(); } catch (Exception e) {
InputStream stream = new Base64.InputStream(binary.getStream(), Base64.ENCODE); try { while (-1 != (len = stream.read(bytes))) {
int b; for (i = 0; i < len; i++) { b = read();
Base64.InputStream bis = new Base64.InputStream(fis, Base64.DECODE);
int b; for (i = 0; i < len; i++) { b = read();
int b; for (i = 0; i < len; i++) { b = read();
private void processPropertyValue( Name name, String value, int propertyType, TextDecoder decoder, List<Value> values ) throws UnsupportedEncodingException, RepositoryException, SAXException { if (propertyType == PropertyType.BINARY) { Base64.InputStream is = new Base64.InputStream(new ByteArrayInputStream(value.getBytes("UTF-8"))); values.add(valueFor(is)); } else { if (decoder != null) value = decoder.decode(value); if (value != null && propertyType == PropertyType.STRING) { // Strings and binaries can be empty -- other data types cannot values.add(valueFor(value, propertyType)); } else if (!StringUtil.isBlank(value) && isReference(propertyType)) { boolean isInternalReference = isInternal(name); if (!isInternalReference) { // we only prepend the parent information for non-internal references value = parentHandler().node().key().withId(value).toString(); } // we only have the identifier of the node, so try to use the parent to determine the workspace & // source key values.add(valueFor(value, propertyType)); } else if (!StringUtil.isBlank(value)) { values.add(valueFor(value, propertyType)); } } }
private void processPropertyValue( Name name, String value, int propertyType, TextDecoder decoder, List<Value> values ) throws UnsupportedEncodingException, RepositoryException, SAXException { if (propertyType == PropertyType.BINARY) { Base64.InputStream is = new Base64.InputStream(new ByteArrayInputStream(value.getBytes("UTF-8"))); values.add(valueFor(is)); } else { if (decoder != null) value = decoder.decode(value); if (value != null && propertyType == PropertyType.STRING) { // Strings and binaries can be empty -- other data types cannot values.add(valueFor(value, propertyType)); } else if (!StringUtil.isBlank(value) && isReference(propertyType)) { boolean isInternalReference = isInternal(name); if (!isInternalReference) { // we only prepend the parent information for non-internal references value = parentHandler().node().key().withId(value).toString(); } // we only have the identifier of the node, so try to use the parent to determine the workspace & // source key values.add(valueFor(value, propertyType)); } else if (!StringUtil.isBlank(value)) { values.add(valueFor(value, propertyType)); } } }
@Test @FixFor("MODE-2413") public void shouldSupportReadingFromSelfClosingInputStream() throws Exception { byte[] buffer = new byte[1024]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); URL resource = getClass().getResource("simple.json"); try (Base64.InputStream is = new Base64.InputStream(new SelfClosingInputStream(resource.openStream()), Base64.ENCODE)) { int read; while ((read = is.read(buffer, 0, buffer.length)) != -1) { bos.write(buffer, 0, read); } } // until Java 8, use this.... String expectedString = DatatypeConverter.printBase64Binary(IoUtil.readBytes(resource.openStream())); assertEquals("Incorrect Base64 encoding", expectedString, new String(bos.toByteArray())); } }
private String jcrValueToString( Value value, int propertyType ) throws RepositoryException { if (value == null) { return ""; } if (PropertyType.BINARY == propertyType) { try { Base64.InputStream is = new Base64.InputStream(value.getBinary().getStream(), Base64.ENCODE); return IoUtil.read(is); } catch (IOException ioe) { throw new RepositoryException(ioe); } } else { return VALUE_ENCODER.encode(value.getString()); } }
private String jcrValueToString( Value value, int propertyType ) throws RepositoryException { if (value == null) { return ""; } if (PropertyType.BINARY == propertyType) { try { Base64.InputStream is = new Base64.InputStream(value.getBinary().getStream(), Base64.ENCODE); return IoUtil.read(is); } catch (IOException ioe) { throw new RepositoryException(ioe); } } else { return VALUE_ENCODER.encode(value.getString()); } }