void setInput(final InputStream in) throws IOException { this.escapeTimeout = Configuration.getLong(JLINE_ESC_TIMEOUT, 100); boolean nonBlockingEnabled = escapeTimeout > 0L && terminal.isSupported() && in != null; /* * If we had a non-blocking thread already going, then shut it down * and start a new one. */ if (this.in != null) { this.in.shutdown(); } final InputStream wrapped = terminal.wrapInIfNeeded( in ); this.in = new NonBlockingInputStream(wrapped, nonBlockingEnabled); this.reader = new InputStreamReader( this.in, encoding ); }
public SystemIoTransport() { reader = new BufferedReader(new InputStreamReader(System.in)); }
String externalForm = format("jar:%s!/%s%s", path.toExternalForm(), EXTENSION_PREFIX, type.getName()); try (InputStreamReader inputStream = new InputStreamReader(new URL(externalForm).openStream())) { final LineReader reader = new LineReader(inputStream); modulesNames.add(reader.readLine());
@Override public <T> Optional<ExtensionLookup> findExtension(ExtensionResolver<T> resolver, Class<T> type) throws IOException, ClassNotFoundException { final Set<String> resources = reflections.getResources(compile(quote(type.getName()))).stream() .filter(r -> r.startsWith(EXTENSION_PREFIX)).collect(toSet()); if (resources.isEmpty()) { return empty(); } final String extensionDescriptor = resources.iterator().next(); final LineReader reader = new LineReader(new InputStreamReader( classLoader.getResourceAsStream(extensionDescriptor))); final String implClassName = reader.readLine(); if (implClassName != null) { final Class<?> implClass = classLoader.loadClass(implClassName); if (type.isAssignableFrom(implClass)) { return of(resolver.asClass(implClass.asSubclass(type))); } if (Provider.class.isAssignableFrom(implClass)) { return of(resolver.asProvider((Class<Provider<? extends T>>) implClass)); } } return empty(); }
void setInput(final InputStream in) throws IOException { this.escapeTimeout = Configuration.getLong(JLINE_ESC_TIMEOUT, 100); boolean nonBlockingEnabled = escapeTimeout > 0L && terminal.isSupported() && in != null; /* * If we had a non-blocking thread already going, then shut it down * and start a new one. */ if (this.in != null) { this.in.shutdown(); } final InputStream wrapped = terminal.wrapInIfNeeded( in ); this.in = new NonBlockingInputStream(wrapped, nonBlockingEnabled); this.reader = new InputStreamReader( this.in, encoding ); }