Returns a new {@link ShellConsole} which uses the supplied
{@link InputStream} and {@link PrintStream} for its input/output
779355
public static ShellConsole getConsole(InputStream in, PrintStream ps,
            Charset cs) {
        return new SimpleShellConsole(in, ps, cs);
    }
1362394
@Override
    public InputStream openStream() {
        try {
            return new BufferedInputStream(new FileInputStream(file), 8192);
        } catch (FileNotFoundException e) {
            throw new RuntimeException("Could not open file " + file, e);
        }
    }
653243
public void createShellStreamSet()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "createShellStreamSet");

        StreamSet streamSet = null;

        synchronized (streamSets)
        {
            streamSet = new StreamSet(null,
                            targetMEUuid,
                            0,
                            isLink ? StreamSet.Type.LINK_INTERNAL_OUTPUT : StreamSet.Type.INTERNAL_OUTPUT);
            streamSets.put(null, streamSet);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createShellStreamSet", streamSet);
    }
888355
public InputStream newInputStream() {
        return new InputStream() {
            private int pos = 0;
            public int read() throws IOException {
                synchronized(ByteBuffer.this) {
                    if(pos>=size)   return -1;
                    return buf[pos++];
                }
            }

            public int read(byte[] b, int off, int len) throws IOException {
                synchronized(ByteBuffer.this) {
                    if(size==pos)
                        return -1;

                    int sz = Math.min(len,size-pos);
                    System.arraycopy(buf,pos,b,off,sz);
                    pos+=sz;
                    return sz;
                }
            }


            public int available() throws IOException {
                synchronized(ByteBuffer.this) {
                    return size-pos;
                }
            }

            public long skip(long n) throws IOException {
                synchronized(ByteBuffer.this) {
                    int diff = (int) Math.min(n,size-pos);
                    pos+=diff;
                    return diff;
                }
            }
        };
    }
605752
public static Pipe newPipe(final InputStream in)
    {
        final CodedInput codedInput = new CodedInput(in, false);
        return new Pipe()
        {
            protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException
            {
                return codedInput;
            }
            protected void end(Pipe.Schema<?> pipeSchema, Input input, 
                    boolean cleanupOnly) throws IOException
            {
                if(cleanupOnly)
                    return;
                
                assert input == codedInput;
            }
        };
    }
401755
@VisibleForTesting
  protected Shell createShell(final IO io, final Variables variables, final Branding branding) throws Exception {
    log.debug("Creating shell instance");

    List<Module> modules = new ArrayList<>();

    URLClassSpace space = new URLClassSpace(getClass().getClassLoader());
    modules.add(new SpaceModule(space, BeanScanning.INDEX));

    final BeanContainer container = new BeanContainer();
    modules.add(BeanContainer.module(container));
    modules.add(binder -> {
      binder.bind(ThreadIO.class).toInstance(threadIO);
      binder.bind(Branding.class).toInstance(branding);
      binder.bind(ShellBuilder.class).to(ShellBuilderImpl.class);
    });

    configure(modules);

    Injector injector = Guice.createInjector(new WireModule(modules));
    // injector is automatically bound to BeanLocator by sisu

    return injector.getInstance(ShellBuilder.class)
      .branding(branding)
      .io(io)
      .variables(variables)
      .build();
  }
735689
private synchronized OutputStream getSocketInputOutputStream(int stream) {
    if (!pipedOutput.containsKey(stream)) {
      try {
        PipedInputStream pipeIn = new PipedInputStream();
        PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);
        pipedOutput.put(stream, pipeOut);
        input.put(stream, pipeIn);
      } catch (IOException ex) {
        // This is _very_ unlikely, as it requires the above constructor to fail.
        // don't force callers to catch, but still throw
        throw new IllegalStateException(ex);
      }
    }
    return pipedOutput.get(stream);
  }
829692
private Stream createStream(IProcessingItem sourcePi) {
        Stream stream = this.componentFactory.createStream(sourcePi);
        this.topology.addStream(stream);
        return stream;
    }
733160
@Override
    public InputStream exportAsInputStream() {
        // Create export delegate
        final AbstractExporterDelegate<InputStream> exportDelegate = new TarExporterDelegate(this.getArchive());

        // Execute export
        return exportDelegate.export();
    }
265999
@Override
    public InputStream newInputStream() throws FileNotFoundException, NewInputStreamException {
        if (isDirectory()) {
            throw new FileNotFoundException(this, "file not found - this is a directory");
        }
        try {
            return Files.newInputStream(path);
        } catch (NoSuchFileException e) {
            throw new FileNotFoundException(this, e);
        } catch (IOException e) {
            throw new NewInputStreamException(this, e);
        }
    }
697247
public static <T> PatternStream<T> pattern(DataStream<T> input, Pattern<T, ?> pattern) {
		return new PatternStream<>(input, pattern);
	}
245782
public static ByteArrayOutputStream input2OutputStream(final InputStream is) {
        if (is == null) return null;
        try {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            byte[]                b  = new byte[MemoryConst.KB];
            int                   len;
            while ((len = is.read(b, 0, MemoryConst.KB)) != -1) {
                os.write(b, 0, len);
            }
            return os;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        } finally {
            IOKit.closeQuietly(is);
        }
    }
710564
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ InputStream.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return InputStream.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
                                  (ContentHandle<C>) new InputStreamHandle() : null;
        return handle;
      }
    };
  }
129819
@Override
    TarInputStream getInputStreamForRawStream(final InputStream in) throws IOException {
        assert in != null : "Specified inputstream was null";
        return new TarInputStream(in);
    }
1024699
@Override
    public T fromStream(final InputStream in) throws IllegalArgumentException, DescriptorImportException {
        return fromStream(in, true);
    }
236998
private static JarInputStream newJarInputStream(InputStream in) throws IOException {
        return new co.paralleluniverse.common.JarInputStream(in);
    }
725114
public static void copyStream( File inputFile, OutputStream os ) throws IOException {
		InputStream is = new FileInputStream( inputFile );
		try {
			copyStreamUnsafelyUseWithCaution( is, os );
		} finally {
			is.close();
		}
	}