public final V get( String key ) throws IOException { if ( key == null ) { return null; } else { this.lock.lock(); V var2; try { var2 = IOUtils.deserialize( (byte[]) this.keyValueMap.get( key ) ); } finally { this.lock.unlock(); } return var2; } }
void save() throws IOException { this.dataFile.createNewFile(); IOUtils.serialize( this.keyValueMap, new FileOutputStream( this.dataFile ) ); }
CustomDataStore( CustomDataStoreFactory dataStore, File dataDirectory, String id ) throws IOException { super( dataStore, id ); this.dataDirectory = dataDirectory; this.dataFile = new File( this.dataDirectory, getId() ); if ( IOUtils.isSymbolicLink( this.dataFile ) ) { throw new IOException( "unable to use a symbolic link: " + this.dataFile ); } this.keyValueMap = Maps.newHashMap(); if ( this.dataFile.exists() ) { this.keyValueMap = (HashMap) IOUtils.deserialize( new FileInputStream( this.dataFile ) ); } }
private String requestRaw(String path) throws IOException { HttpRequest getRequest = TRANSPORT.createRequestFactory().buildGetRequest( new GenericUrl(baseUrl + path)); HttpHeaders headers = new HttpHeaders(); headers.setAuthorization("Bearer " + accessToken); getRequest.setHeaders(headers); HttpResponse response = getRequest.execute(); validateResponse(getRequest, response, 200); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); IOUtils.copy(response.getContent(), byteArrayOutputStream, true); return byteArrayOutputStream.toString(); }
public CustomDataStoreFactory( File dataDirectory ) throws IOException { dataDirectory = dataDirectory.getCanonicalFile(); this.dataDirectory = dataDirectory; if ( IOUtils.isSymbolicLink( dataDirectory ) ) { throw new IOException( "unable to use a symbolic link: " + dataDirectory ); } else if ( !dataDirectory.exists() && !dataDirectory.mkdirs() ) { throw new IOException( "unable to create directory: " + dataDirectory ); } }
LowLevelHttpResponse lowLevelHttpResponse = (LowLevelHttpResponse) responseField.get(httpResponse); IOUtils.copy(lowLevelHttpResponse.getContent(), output); } catch (IllegalAccessException | NoSuchFieldException ex) { throw new StorageException(
@Override protected String doGetContent() throws IOException { try (InputStream is = response.getContent(); ByteArrayOutputStream bos = new ByteArrayOutputStream()) { copy(is, bos); return new String(bos.toByteArray(), response.getContentCharset()); } } }
public final DataStore<V> set( String key, V value ) throws IOException { Preconditions.checkNotNull( key ); Preconditions.checkNotNull( value ); this.lock.lock(); try { this.keyValueMap.put( key, IOUtils.serialize( value ) ); this.save(); } finally { this.lock.unlock(); } return this; }
public final Collection<V> values() throws IOException { this.lock.lock(); try { List<V> result = Lists.newArrayList(); Iterator i$ = this.keyValueMap.values().iterator(); while ( i$.hasNext() ) { byte[] bytes = (byte[]) i$.next(); result.add( IOUtils.deserialize( bytes ) ); } List var7 = Collections.unmodifiableList( result ); return var7; } finally { this.lock.unlock(); } }
@Override public void handlePdf(File pdfFile) { try { if (pdfFile != null) { headers.put("Content-disposition", "attachment; filename=\"" + args.get("name") +"\""); brh.setContentType("application/pdf", headers); FileInputStream is = new FileInputStream(pdfFile); IOUtils.copy(is, brh.getOutputStream(), true); } else { brh.setContentType("text/plain", headers); brh.getOutputStream().write("Oups! Failed to export pdf!".getBytes()); } } catch (IOException e) { logger.warn("Failed! {}", args, e); } } });
<V extends Serializable> void serialize(V value) throws IOException { bytes = IOUtils.serialize(value); }
<V extends Serializable> V deserialize() throws IOException { return IOUtils.deserialize(bytes); }
IOUtils.copy(inputStream, outStream);
@Override public AppEngineDataStore<V> set(String key, V value) throws IOException { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); lock.lock(); try { Entity entity = new Entity(getId(), key); entity.setUnindexedProperty(FIELD_VALUE, new Blob(IOUtils.serialize(value))); dataStoreService.put(entity); if (memcache != null) { memcache.put(key, value, memcacheExpiration); } } finally { lock.unlock(); } return this; }
/** Deserializes the specified object from a Blob using an {@link ObjectInputStream}. */ private V deserialize(Entity entity) throws IOException { Blob blob = (Blob) entity.getProperty(FIELD_VALUE); return IOUtils.deserialize(blob.getBytes()); }
IOUtils.copy(response.getContent(), outputStream); } finally { response.disconnect();
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out, false); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out, false); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
LowLevelHttpResponse lowLevelHttpResponse = (LowLevelHttpResponse) responseField.get(httpResponse); IOUtils.copy(lowLevelHttpResponse.getContent(), output); } catch (IllegalAccessException | NoSuchFieldException ex) { throw new StorageException(