com.google.common.io.LimitInputStream Java Examples
The following examples show how to use
com.google.common.io.LimitInputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Closure_101_CommandLineRunner_s.java From coming with MIT License | 5 votes |
/** * @return a mutable list * @throws IOException */ private List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); List<JSSourceFile> externs = Lists.newLinkedList(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null; ) { LimitInputStream entryStream = new LimitInputStream(zip, entry.getSize()); externs.add(JSSourceFile.fromInputStream(entry.getName(), entryStream)); } return externs; }
Example #2
Source File: Closure_101_CommandLineRunner_t.java From coming with MIT License | 5 votes |
/** * @return a mutable list * @throws IOException */ private List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); List<JSSourceFile> externs = Lists.newLinkedList(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null; ) { LimitInputStream entryStream = new LimitInputStream(zip, entry.getSize()); externs.add(JSSourceFile.fromInputStream(entry.getName(), entryStream)); } return externs; }
Example #3
Source File: Closure_83_CommandLineRunner_t.java From coming with MIT License | 5 votes |
/** * @return a mutable list * @throws IOException */ public static List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); Map<String, JSSourceFile> externsMap = Maps.newHashMap(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null; ) { LimitInputStream entryStream = new LimitInputStream(zip, entry.getSize()); externsMap.put(entry.getName(), JSSourceFile.fromInputStream( // Give the files an odd prefix, so that they do not conflict // with the user's files. "externs.zip//" + entry.getName(), entryStream)); } Preconditions.checkState( externsMap.keySet().equals(Sets.newHashSet(DEFAULT_EXTERNS_NAMES)), "Externs zip must match our hard-coded list of externs."); // Order matters, so the resources must be added to the result list // in the expected order. List<JSSourceFile> externs = Lists.newArrayList(); for (String key : DEFAULT_EXTERNS_NAMES) { externs.add(externsMap.get(key)); } return externs; }
Example #4
Source File: Closure_83_CommandLineRunner_s.java From coming with MIT License | 5 votes |
/** * @return a mutable list * @throws IOException */ public static List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); Map<String, JSSourceFile> externsMap = Maps.newHashMap(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null; ) { LimitInputStream entryStream = new LimitInputStream(zip, entry.getSize()); externsMap.put(entry.getName(), JSSourceFile.fromInputStream( // Give the files an odd prefix, so that they do not conflict // with the user's files. "externs.zip//" + entry.getName(), entryStream)); } Preconditions.checkState( externsMap.keySet().equals(Sets.newHashSet(DEFAULT_EXTERNS_NAMES)), "Externs zip must match our hard-coded list of externs."); // Order matters, so the resources must be added to the result list // in the expected order. List<JSSourceFile> externs = Lists.newArrayList(); for (String key : DEFAULT_EXTERNS_NAMES) { externs.add(externsMap.get(key)); } return externs; }
Example #5
Source File: ClosureJavaScriptCompressor.java From htmlcompressor with Apache License 2.0 | 5 votes |
private List<JSSourceFile> getDefaultExterns() throws IOException { InputStream input = ClosureJavaScriptCompressor.class.getResourceAsStream("/externs.zip"); ZipInputStream zip = new ZipInputStream(input); List<JSSourceFile> externs = Lists.newLinkedList(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null;) { LimitInputStream entryStream = new LimitInputStream(zip, entry.getSize()); externs.add(JSSourceFile.fromInputStream(entry.getName(), entryStream)); } return externs; }
Example #6
Source File: CommandLineRunner.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @return a mutable list * @throws IOException */ public static List<SourceFile> getDefaultExterns() throws IOException { InputStream input = CommandLineRunner.class.getResourceAsStream( "/externs.zip"); if (input == null) { // In some environments, the externs.zip is relative to this class. input = CommandLineRunner.class.getResourceAsStream("externs.zip"); } Preconditions.checkNotNull(input); ZipInputStream zip = new ZipInputStream(input); Map<String, SourceFile> externsMap = Maps.newHashMap(); for (ZipEntry entry = null; (entry = zip.getNextEntry()) != null; ) { BufferedInputStream entryStream = new BufferedInputStream( new LimitInputStream(zip, entry.getSize())); externsMap.put(entry.getName(), SourceFile.fromInputStream( // Give the files an odd prefix, so that they do not conflict // with the user's files. "externs.zip//" + entry.getName(), entryStream)); } Preconditions.checkState( externsMap.keySet().equals(Sets.newHashSet(DEFAULT_EXTERNS_NAMES)), "Externs zip must match our hard-coded list of externs."); // Order matters, so the resources must be added to the result list // in the expected order. List<SourceFile> externs = Lists.newArrayList(); for (String key : DEFAULT_EXTERNS_NAMES) { externs.add(externsMap.get(key)); } return externs; }