Refine search
rbc = new RBCWrapper( Channels.newChannel( url.openStream() ), contentLength( url ), this ); fos = new FileOutputStream( localPath ); fos.getChannel().transferFrom( rbc, 0, Long.MAX_VALUE ); public void close() throws IOException { rbc.close(); } public long getReadSoFar() { return readSoFar; } public boolean isOpen() { return rbc.isOpen(); }
final InputStream input = new FileInputStream(inputFile); final OutputStream output = new FileOutputStream(outputFile); final ReadableByteChannel inputChannel = Channels.newChannel(input); final WriteableByteChannel outputChannel = Channels.newChannel(output); ChannelTools.fastChannelCopy(inputChannel, outputChannel); inputChannel.close(); outputChannel.close()
fd = new ChannelFD(Channels.newChannel(runtime.getIn()), runtime.getPosix(), runtime.getFilenoUtil()); break; case 1: fd = new ChannelFD(Channels.newChannel(runtime.getOut()), runtime.getPosix(), runtime.getFilenoUtil()); break; case 2: fd = new ChannelFD(Channels.newChannel(runtime.getErr()), runtime.getPosix(), runtime.getFilenoUtil()); break; default: if (!fd.ch.isOpen()) { throw runtime.newErrnoEBADFError();
private void closeChannel(final Channel channel) throws IOException { if (channel != null) try { channel.close(); } catch (ClosedChannelException ignored) {} }
/** * Whether the channel associated with this descriptor is open. * * @return true if the associated channel is open, false otherwise */ public boolean isOpen() { return channel.isOpen(); }
Channel selected = channelChoiceBox.getSelectionModel().getSelectedItem(); Channel newChan = new Channel("Example", "Channel"); replaceChannel(newChan, selected);
public static void downloadFileFromURL(String urlString, File destination) { try { URL website = new URL(urlString); ReadableByteChannel rbc; rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(destination); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); fos.close(); rbc.close(); } catch (IOException e) { e.printStackTrace(); } }
fd = new ChannelFD(Channels.newChannel(runtime.getIn()), runtime.getPosix(), runtime.getFilenoUtil()); break; case 1: fd = new ChannelFD(Channels.newChannel(runtime.getOut()), runtime.getPosix(), runtime.getFilenoUtil()); break; case 2: fd = new ChannelFD(Channels.newChannel(runtime.getErr()), runtime.getPosix(), runtime.getFilenoUtil()); break; default: if (!fd.ch.isOpen()) { throw runtime.newErrnoEBADFError();
private void quietlyClose(Channel channel) { try { channel.close(); } catch (IOException e) { logger.warn("exception on closing channel:{} \n {}", channel, e); } }
/** * Whether the channel associated with this descriptor is open. * * @return true if the associated channel is open, false otherwise */ public boolean isOpen() { return channel.isOpen(); }
System.setProperty("java.net.preferIPv4Stack", "true"); Channel channel = new JChannel("udp.xml"); channel.connect("test-cluster");
input = Channels.newChannel(resource.getInputStream()); output = Channels.newChannel(externalContext.getResponseOutputStream()); if (output != null) try { output.close(); } catch (IOException ignore) {} if (input != null) try { input.close(); } catch (IOException ignore) {}
ReadableByteChannel stdoutChannel = Channels.newChannel(p.getInputStream()); ReadableByteChannel stderrChannel = Channels.newChannel(p.getErrorStream()); ByteBuffer buffer = ByteBuffer.allocate(1000); StringBuilder stdErr = new StringBuilder(); while(stdoutChannel.isOpen() || stderrChannel.isOpen()) { buffer.clear(); if(stderrChannel.isOpen()) { int bytesRead = stderrChannel.read(buffer); if(bytesRead>0) stdErr.append(new String(buffer.array(),0,bytesRead)); if(bytesRead==-1) stderrChannel.close(); if(stdoutChannel.isOpen()) { int bytesRead = stdoutChannel.read(buffer); if(bytesRead>0) stdOut.append(new String(buffer.array(),0,bytesRead)); if(bytesRead==-1) stdoutChannel.close();
public void closeChannel(Channel channel) throws IOException { channel.close(); } }
/** * Whether the channel associated with this descriptor is open. * * @return true if the associated channel is open, false otherwise */ public boolean isOpen() { return channel.isOpen(); }
Channel channel = new Channel(1234); Entry entry = channel.getLastChannelEntry(); System.out.println(entry.getField(1);
void copyStreamToFile(InputStream in, File outputFile, boolean doDeleteOnExit) { //Clean up file after VM exit, if needed. if(doDeleteOnExit) outputFile.deleteOnExit(); FileOutputStream outputStream = new FileOutputStream(outputFile); ReadableByteChannel inputChannel = Channels.newChannel(in); WritableByteChannel outputChannel = Channels.newChannel(outputStream); ChannelTools.fastChannelCopy(inputChannel, outputChannel); inputChannel.close(); outputChannel.close() }