Java Code Examples for java.io.InputStream

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ACLS-protocol-library, under directory /aclslib/src/main/java/au/edu/uq/cmm/aclslib/config/.

Source file: JsonConfigLoader.java

  45 
vote

/** 
 * Load the configuration from a file.
 * @param configFile
 * @return the configuration or null if it couldn't be found / read.
 * @throws ConfigurationException 
 */
public C loadConfiguration(String configFile) throws ConfigurationException {
  InputStream is=null;
  try {
    File cf=new File(configFile == null ? "config.json" : configFile);
    is=new FileInputStream(cf);
    return readConfiguration(is);
  }
 catch (  IOException ex) {
    throw new ConfigurationException("Cannot open file '" + configFile + "'",ex);
  }
 finally {
    closeQuietly(is);
  }
}
 

Example 2

From project action-core, under directory /src/test/java/com/ning/metrics/action/hdfs/data/parser/.

Source file: TestSmileRowSerializer.java

  36 
vote

@Test(groups="fast") public void testToRowsOrderingWithoutRegistrar() throws Exception {
  final Map<String,Object> eventMap=createEventMap();
  final ByteArrayOutputStream out=createSmileEnvelopePayload(eventMap);
  final InputStream stream=new ByteArrayInputStream(out.toByteArray());
  final SmileRowSerializer serializer=new SmileRowSerializer();
  final Rows rows=serializer.toRows(new NullRegistrar(),stream);
  final RowSmile firstRow=(RowSmile)rows.iterator().next();
  final ImmutableMap<String,ValueNode> actual=firstRow.toMap();
  Assert.assertEquals(actual.keySet().size(),eventMap.keySet().size() + 2);
  Assert.assertNotNull(actual.get("eventDate"));
  Assert.assertEquals(actual.get("eventGranularity"),"HOURLY");
  Assert.assertEquals(actual.get("field1"),eventMap.get("field1"));
  Assert.assertEquals(actual.get("field2"),eventMap.get("field2"));
}
 

Example 3

From project adbcj, under directory /api/src/test/java/org/adbcj/support/.

Source file: DecoderInputStreamTest.java

  35 
vote

@Test public void boundingTest() throws IOException {
  InputStream in=new ByteArrayInputStream(new byte[]{0,1});
  InputStream din=new DecoderInputStream(in,1);
  din.read();
  try {
    din.read();
    Assert.fail("Should have thrown indicating limit exceeded");
  }
 catch (  IllegalStateException e) {
  }
}
 

Example 4

From project addis, under directory /application/src/main/java/org/drugis/addis/.

Source file: AppInfo.java

  35 
vote

private static String getProperty(String property,String fallback){
  try {
    InputStream is=AppInfo.class.getResourceAsStream("/META-INF/maven/org.drugis.addis/application/pom.properties");
    Properties props=new Properties();
    props.load(is);
    return props.getProperty(property,fallback);
  }
 catch (  Exception e) {
    return fallback;
  }
}
 

Example 5

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  34 
vote

/** 
 * This returns whether something has been persisted to the URI of the specified resource. The implementation uses the URI converter from the editor's resource set to try to open an input stream.  <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected boolean isPersisted(Resource resource){
  boolean result=false;
  try {
    InputStream stream=editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
    if (stream != null) {
      result=true;
      stream.close();
    }
  }
 catch (  IOException e) {
  }
  return result;
}
 

Example 6

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial/src/org/eclipse/acceleo/tutorial/wizard/.

Source file: EclipseConWizard.java

  34 
vote

public static void writeFile(File file,IFolder folder,IProgressMonitor monitor){
  String emtlContent=getFileContent(file);
  IFile newFile=folder.getFile(file.getName());
  if (!newFile.exists()) {
    InputStream contents=new ByteArrayInputStream(emtlContent.getBytes());
    try {
      newFile.create(contents,true,monitor);
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
  }
}
 

Example 7

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.

Source file: ACEEditor.java

  34 
vote

/** 
 * Returns information about ACE Editor, like the version number and the release date. This information is read from the file "aceeditor.properties".
 * @param key The key string.
 * @return The value for the given key.
 */
public static String getInfo(String key){
  if (properties == null) {
    String f="ch/uzh/ifi/attempto/aceeditor/aceeditor.properties";
    InputStream in=Thread.currentThread().getContextClassLoader().getResourceAsStream(f);
    properties=new Properties();
    try {
      properties.load(in);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
  return properties.getProperty(key);
}
 

Example 8

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/ui/process/.

Source file: ProcessDefinitionImageStreamResourceBuilder.java

  33 
vote

public StreamResource buildStreamResource(ProcessDefinition processDefinition,RepositoryService repositoryService){
  StreamResource imageResource=null;
  if (processDefinition.getDiagramResourceName() != null) {
    final InputStream definitionImageStream=repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),processDefinition.getDiagramResourceName());
    StreamSource streamSource=new InputStreamStreamSource(definitionImageStream);
    String imageExtension=extractImageExtension(processDefinition.getDiagramResourceName());
    String fileName=processDefinition.getId() + "." + imageExtension;
    imageResource=new StreamResource(streamSource,fileName,ExplorerApp.get());
  }
  return imageResource;
}
 

Example 9

From project Activiti-KickStart, under directory /activiti-kickstart-java/src/test/java/org/activiti/kickstart/.

Source file: KickstartTest.java

  33 
vote

@Test public void testAdhocWorkflowDiagram() throws Exception {
  KickstartWorkflow wf=new KickstartWorkflow();
  wf.setName("Test process");
  wf.setTasks(getTaskList());
  assertEquals("Test process",wf.getName());
  assertEquals(2,wf.getTasks().size());
  ProcessDiagramGenerator diagramGenerator=new ProcessDiagramGenerator(wf,new MarshallingServiceImpl());
  InputStream diagram=diagramGenerator.execute();
  byte[] data=getBytesFromInputStream(diagram);
  assertNotNull(data);
  assertTrue("byte array is not empty",data.length > 0);
}
 

Example 10

From project AdServing, under directory /modules/utilities/common/src/main/java/net/mad/ads/common/util/.

Source file: Properties2.java

  33 
vote

static public Properties loadProperties(File propertiesFile) throws IOException {
  InputStream is=null;
  is=new FileInputStream(propertiesFile);
  Properties prop=new Properties();
  prop.load(is);
  return new XProperties(prop);
}
 

Example 11

From project aerogear-controller, under directory /src/main/java/org/jboss/aerogear/controller/router/.

Source file: ErrorServlet.java

  33 
vote

/** 
 * Reads the template and makes Throwable available as a variable named 'exception'.  </p> The template language used by this method is MVEL2 (http://mvel.codehaus.org/).
 * @param templatePath the path to the template used for displaying the exception.
 * @param throwable the exception to be used in the target template.
 * @return {@code String} the result of  processing the passed-in template.
 */
@SuppressWarnings("resource") public static String readTemplate(final String templatePath,final Throwable throwable){
  InputStream in=null;
  try {
    in=ErrorServlet.class.getResourceAsStream(templatePath);
    final Map<String,Object> vars=new HashMap<String,Object>();
    vars.put("exception",throwable);
    return (String)TemplateRuntime.eval(in,vars);
  }
  finally {
    safeClose(in);
  }
}
 

Example 12

From project aether-core, under directory /aether-test-util/src/main/java/org/eclipse/aether/internal/test/util/.

Source file: DependencyGraphParser.java

  33 
vote

/** 
 * Parse the graph definition read from the given URL.
 */
public DependencyNode parse(URL resource) throws IOException {
  InputStream stream=null;
  try {
    stream=resource.openStream();
    return parse(new BufferedReader(new InputStreamReader(stream,"UTF-8")));
  }
  finally {
    if (stream != null) {
      stream.close();
    }
  }
}
 

Example 13

From project agile, under directory /agile-framework/src/main/java/org/apache/catalina/servlets/.

Source file: DefaultServlet.java

  33 
vote

/** 
 * Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception).
 * @param resourceInfo The ResourceInfo object
 * @param ostream The output stream to write to
 * @param range Range the client wanted to retrieve
 * @exception IOException if an input/output error occurs
 */
protected void copy(CacheEntry cacheEntry,ServletOutputStream ostream,Range range) throws IOException {
  IOException exception=null;
  InputStream resourceInputStream=cacheEntry.resource.streamContent();
  InputStream istream=new BufferedInputStream(resourceInputStream,input);
  exception=copyRange(istream,ostream,range.start,range.end);
  istream.close();
  if (exception != null)   throw exception;
}
 

Example 14

From project agit, under directory /agit-test-utils/src/main/java/com/madgag/agit/matchers/.

Source file: GitTestHelper.java

  33 
vote

public File unpackRepoAndGetGitDir(String fileName) throws IOException, ArchiveException {
  InputStream rawZipFileInputStream=environment.streamFor(fileName);
  assertThat("Stream for " + fileName,rawZipFileInputStream,notNullValue());
  File repoParentFolder=newFolder("unpacked-" + fileName);
  unzip(rawZipFileInputStream,repoParentFolder);
  rawZipFileInputStream.close();
  return repoParentFolder;
}
 

Example 15

From project agorava-core, under directory /agorava-core-impl/src/main/java/org/agorava/core/oauth/scribe/.

Source file: RestResponseScribe.java

  33 
vote

/** 
 * {@inheritDoc}This implementation support also gzip encoding in the response
 * @return
 */
@Override public InputStream getStream(){
  InputStream res;
  if (GZIP_CONTENT_ENCODING.equals(getHeaders().get(CONTENT_ENCODING)))   try {
    res=new GZIPInputStream(getDelegate().getStream());
  }
 catch (  IOException e) {
    throw new AgoravaException("Unable to create GZIPInputStream",e);
  }
 else   res=getDelegate().getStream();
  return res;
}
 

Example 16

From project agraph-java-client, under directory /src/com/franz/agraph/http/.

Source file: AGHTTPClient.java

  33 
vote

protected final void releaseConnection(HttpMethod method){
  try {
    InputStream responseStream=method.getResponseBodyAsStream();
    if (responseStream != null) {
      while (responseStream.read() >= 0) {
      }
    }
    method.releaseConnection();
  }
 catch (  IOException e) {
    logger.warn("I/O error upon releasing connection",e);
  }
}
 

Example 17

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Commands/.

Source file: cmdRebuild.java

  32 
vote

private boolean downloadSkin(String playerName){
  int len1=0;
  InputStream is=null;
  OutputStream os=null;
  try {
    URL url=new URL("http://s3.amazonaws.com/MinecraftSkins/" + playerName + ".png");
    is=url.openStream();
    os=new FileOutputStream(new File(Core.getInstance().getDataFolder(),"/skins/" + playerName + ".png"));
    byte[] buff=new byte[4096];
    while (-1 != (len1=is.read(buff))) {
      os.write(buff,0,len1);
    }
    os.flush();
  }
 catch (  Exception ex) {
    return false;
  }
 finally {
    if (os != null)     try {
      os.close();
    }
 catch (    IOException ex) {
    }
    if (is != null)     try {
      is.close();
    }
 catch (    IOException ex) {
    }
  }
  return true;
}
 

Example 18

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/typeloader/.

Source file: AntlibTypeInfo.java

  32 
vote

private static List<Pair<String,String>> readTaskListingFromPropertiesFile(String resourceName){
  URL url=AntlibTypeLoader.class.getClassLoader().getResource(resourceName);
  InputStream in=null;
  try {
    in=url.openStream();
    if (in == null) {
      AntlibTypeLoader.log("Could not load definitions from " + url,Project.MSG_WARN);
    }
    Properties tasks=new Properties();
    tasks.load(in);
    List<Pair<String,String>> listing=new ArrayList<Pair<String,String>>();
    for (    Map.Entry<Object,Object> entry : tasks.entrySet()) {
      listing.add(new Pair<String,String>((String)entry.getKey(),(String)entry.getValue()));
    }
    return listing;
  }
 catch (  IOException e) {
    throw GosuExceptionUtil.forceThrow(e);
  }
 finally {
    FileUtils.close(in);
  }
}
 

Example 19

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SuggestionsAdapter.java

  32 
vote

/** 
 * Gets a drawable by URI, without using the cache.
 * @return A drawable, or {@code null} if the drawable could not be loaded.
 */
private Drawable getDrawable(Uri uri){
  try {
    String scheme=uri.getScheme();
    if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(scheme)) {
      try {
        return getTheDrawable(uri);
      }
 catch (      Resources.NotFoundException ex) {
        throw new FileNotFoundException("Resource does not exist: " + uri);
      }
    }
 else {
      InputStream stream=mProviderContext.getContentResolver().openInputStream(uri);
      if (stream == null) {
        throw new FileNotFoundException("Failed to open " + uri);
      }
      try {
        return Drawable.createFromStream(stream,null);
      }
  finally {
        try {
          stream.close();
        }
 catch (        IOException ex) {
          Log.e(LOG_TAG,"Error closing icon stream for " + uri,ex);
        }
      }
    }
  }
 catch (  FileNotFoundException fnfe) {
    Log.w(LOG_TAG,"Icon not found: " + uri + ", "+ fnfe.getMessage());
    return null;
  }
}
 

Example 20

From project activejdbc, under directory /activejdbc-instrumentation/src/main/java/org/javalite/instrumentation/.

Source file: InstrumentationModelFinder.java

  32 
vote

/** 
 * Finds and processes property files inside zip or jar files.
 * @param file zip or jar file.
 */
private void processFilePath(File file){
  try {
    if (file.getCanonicalPath().toLowerCase().endsWith(".jar") || file.getCanonicalPath().toLowerCase().endsWith(".zip")) {
      ZipFile zip=new ZipFile(file);
      Enumeration<? extends ZipEntry> entries=zip.entries();
      while (entries.hasMoreElements()) {
        ZipEntry entry=entries.nextElement();
        if (entry.getName().endsWith("class")) {
          InputStream zin=zip.getInputStream(entry);
          classFound(entry.getName().replace(File.separatorChar,'.').substring(0,entry.getName().length() - 6));
          zin.close();
        }
      }
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
catch (  ClassNotFoundException ignore) {
  }
}
 

Example 21

From project activemq-apollo, under directory /apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/command/.

Source file: ActiveMQObjectMessage.java

  32 
vote

/** 
 * Gets the serializable object containing this message's data. The default value is null.
 * @return the serializable object containing this message's data
 * @throws OpenwireException
 */
public Serializable getObject() throws OpenwireException {
  if (object == null && getContent() != null) {
    try {
      Buffer content=getContent();
      InputStream is=new ByteArrayInputStream(content);
      if (isCompressed()) {
        is=new InflaterInputStream(is);
      }
      DataInputStream dataIn=new DataInputStream(is);
      ClassLoadingAwareObjectInputStream objIn=new ClassLoadingAwareObjectInputStream(dataIn);
      try {
        object=(Serializable)objIn.readObject();
      }
 catch (      ClassNotFoundException ce) {
        throw new OpenwireException("Failed to build body from content. Serializable class not available to broker. Reason: " + ce,ce);
      }
 finally {
        dataIn.close();
      }
    }
 catch (    IOException e) {
      throw new OpenwireException("Failed to build body from bytes. Reason: " + e,e);
    }
  }
  return this.object;
}
 

Example 22

From project activiti-webapp-rest-generic, under directory /activiti-webapp-rest/src/main/java/org/activiti/rest/api/process/.

Source file: ProcessDefinitionFormGet.java

  32 
vote

/** 
 * Returns a task form
 * @param req The activiti webscript request
 * @param res The webscript response
 */
@Override protected void executeStreamingWebScript(ActivitiRequest req,WebScriptResponse res){
  String processDefinitionId=req.getMandatoryPathParameter("processDefinitionId");
  Object form=getFormService().getRenderedStartForm(processDefinitionId);
  InputStream is=null;
  if (form != null && form instanceof String) {
    is=new ByteArrayInputStream(((String)form).getBytes());
  }
 else   if (form != null && form instanceof InputStream) {
    is=(InputStream)form;
  }
  if (is != null) {
    String mimeType=getMimeType(is);
    try {
      streamResponse(res,is,new Date(0),null,true,processDefinitionId,mimeType);
    }
 catch (    IOException e) {
      throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,"The form for process definition '" + processDefinitionId + "' failed to render.");
    }
 finally {
      IoUtil.closeSilently(is);
    }
  }
 else   if (form != null) {
    throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,"The form for process definition '" + processDefinitionId + "' cannot be rendered using the rest api.");
  }
 else {
    throw new WebScriptException(Status.STATUS_NOT_FOUND,"There is no form for process definition '" + processDefinitionId + "'.");
  }
}
 

Example 23

From project adg-android, under directory /src/com/analysedesgeeks/android/service/impl/.

Source file: DownloadServiceImpl.java

  32 
vote

@Override public boolean downloadFeed(){
  boolean downloadSuccess=false;
  if (connectionService.isConnected()) {
    InputStream inputStream=null;
    try {
      final HttpGet httpget=new HttpGet(new URI(Const.FEED_URL));
      final HttpResponse response=new DefaultHttpClient().execute(httpget);
      final StatusLine status=response.getStatusLine();
      if (status.getStatusCode() != HttpStatus.SC_OK) {
        Ln.e("Erreur lors du t??hargement:%s,%s",status.getStatusCode(),status.getReasonPhrase());
      }
 else {
        final HttpEntity entity=response.getEntity();
        inputStream=entity.getContent();
        final ByteArrayOutputStream content=new ByteArrayOutputStream();
        int readBytes=0;
        final byte[] sBuffer=new byte[512];
        while ((readBytes=inputStream.read(sBuffer)) != -1) {
          content.write(sBuffer,0,readBytes);
        }
        final String dataAsString=new String(content.toByteArray());
        final List<FeedItem> syndFeed=rssService.parseRss(dataAsString);
        if (syndFeed != null) {
          databaseService.save(dataAsString);
          downloadSuccess=true;
        }
      }
    }
 catch (    final Throwable t) {
      Ln.e(t);
    }
 finally {
      closeQuietly(inputStream);
    }
  }
  return downloadSuccess;
}
 

Example 24

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/.

Source file: ViewTools.java

  32 
vote

public String getCommitUrl() throws IOException, CantDoThatException {
  String commitFileName=this.request.getSession().getServletContext().getRealPath("/lastcommit.txt");
  File commitFile=new File(commitFileName);
  try {
    InputStream inputStream=new FileInputStream(commitFileName);
    BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream,Charset.forName("UTF-8")));
    String commitLine=reader.readLine();
    String commitId=commitLine.replace("commit ","");
    inputStream.close();
    return "https://github.com/okohll/agileBase/commit/" + commitId;
  }
 catch (  FileNotFoundException fnfex) {
    logger.error("Commit file " + commitFileName + " not found: "+ fnfex);
    throw new CantDoThatException("Commit log not found");
  }
}
 

Example 25

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: Utility.java

  32 
vote

final static public Image loadImage(final String fileName){
  String keyName=fileName.trim().toLowerCase();
  Image cacheImage=(Image)cacheImages.get(keyName);
  if (cacheImage == null) {
    InputStream in=new BufferedInputStream(classLoader.getResourceAsStream(fileName));
    ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
    try {
      byte[] bytes=new byte[8192];
      int read;
      while ((read=in.read(bytes)) >= 0) {
        byteArrayOutputStream.write(bytes,0,read);
      }
      byte[] arrayByte=byteArrayOutputStream.toByteArray();
      cacheImages.put(keyName,cacheImage=toolKit.createImage(arrayByte));
      mediaTracker.addImage(cacheImage,0);
      mediaTracker.waitForID(0);
      waitImage(100,cacheImage);
    }
 catch (    Exception e) {
      throw new RuntimeException(fileName + " not found!");
    }
 finally {
      try {
        if (byteArrayOutputStream != null) {
          byteArrayOutputStream.close();
          byteArrayOutputStream=null;
        }
        if (in != null) {
          in.close();
        }
      }
 catch (      IOException e) {
      }
    }
  }
  if (cacheImage == null) {
    throw new RuntimeException(("File not found. ( " + fileName + " )").intern());
  }
  return cacheImage;
}
 

Example 26

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: BinaryUtils.java

  30 
vote

public static String read3dsstring(InputStream stream){
  String s="";
  int i=0;
  int l_char='\0';
  do {
    if (l_char != '\0')     s+=((char)l_char);
    try {
      l_char=stream.read();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    i++;
  }
 while (l_char != '\0' && i < maxchars);
  return s;
}
 

Example 27

From project 4308Cirrus, under directory /tendril-android-lib/src/test/java/edu/colorado/cs/cirrus/android/.

Source file: DeserializationTest.java

  30 
vote

@Test public void canDeserializeMeterReading(){
  RestTemplate restTemplate=new RestTemplate();
  restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpUtils.getNewHttpClient()));
  HttpInputMessage him=new HttpInputMessage(){
    public HttpHeaders getHeaders(){
      return new HttpHeaders();
    }
    public InputStream getBody() throws IOException {
      return new FileInputStream(new File("src/test/resources/MeterReadings.xml"));
    }
  }
;
  for (  HttpMessageConverter<?> hmc : restTemplate.getMessageConverters()) {
    System.out.println("hmc: " + hmc);
    if (hmc.canRead(MeterReadings.class,MediaType.APPLICATION_XML)) {
      HttpMessageConverter<MeterReadings> typedHmc=(HttpMessageConverter<MeterReadings>)hmc;
      System.out.println("Can Read: " + hmc);
      hmc.canRead(MeterReadings.class,MediaType.APPLICATION_XML);
      try {
        MeterReadings mr=(MeterReadings)typedHmc.read(MeterReadings.class,him);
        System.out.println(mr);
      }
 catch (      HttpMessageNotReadableException e) {
        e.printStackTrace();
        fail();
      }
catch (      IOException e) {
        e.printStackTrace();
        fail();
      }
    }
  }
}
 

Example 28

From project AdminCmd, under directory /src/main/java/be/Balor/Tools/Configuration/File/.

Source file: ExFileConfiguration.java

  30 
vote

/** 
 * Loads this  {@link ExFileConfiguration} from the specified stream.<p> All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.
 * @param stream Stream to load from
 * @throws IOException Thrown when the given file cannot be read.
 * @throws InvalidConfigurationException Thrown when the given file is not a valid Configuration.
 * @throws IllegalArgumentException Thrown when stream is null.
 */
public void load(final InputStream stream) throws IOException, InvalidConfigurationException {
  if (stream == null) {
    throw new IllegalArgumentException("Stream cannot be null");
  }
  final StringBuilder builder=new StringBuilder();
  final BufferedReader input=new BufferedReader(new UnicodeReader(stream,"UTF-8"));
  try {
    String line;
    while ((line=input.readLine()) != null) {
      builder.append(line);
      builder.append('\n');
    }
  }
  finally {
    input.close();
  }
  loadFromString(builder.toString());
}
 

Example 29

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/discovery/.

Source file: NDKDiscoveryUpdater.java

  30 
vote

private void checkIncludes(InputStream in){
  try {
    List<String> includes=new ArrayList<String>();
    boolean inIncludes1=false;
    boolean inIncludes2=false;
    BufferedReader reader=new BufferedReader(new InputStreamReader(in));
    String line=reader.readLine();
    while (line != null) {
      if (!inIncludes1) {
        if (line.equals("#include \"...\" search starts here:"))         inIncludes1=true;
      }
 else {
        if (!inIncludes2) {
          if (line.equals("#include <...> search starts here:"))           inIncludes2=true;
 else           includes.add(line.trim());
        }
 else {
          if (line.equals("End of search list.")) {
            pathInfo.setIncludePaths(includes);
          }
 else {
            includes.add(line.trim());
          }
        }
      }
      line=reader.readLine();
    }
  }
 catch (  IOException e) {
  }
}