Java Code Examples for java.io.BufferedInputStream

The following code examples are extracted from open source projects. You can click to vote up the examples you like. The votes will be used to predict good API usage examples and more good examples will be extracted based on the votes.

Code Example 1:

  3 
vote

From project sitemesh2, under directory /testsuite/src/java/testsuite/sitemesh/.

Source BinaryFileTest.java

public void testImageIsDownloadedIntact() throws Exception {
    InputStream fis = new BufferedInputStream(new FileInputStream("src/webapp/binary/harry_potter.gif"));
    WebResponse rs = wc.getResponse(baseUrl + "/binary/harry_potter.gif");
    InputStream wis = rs.getInputStream();

    int f, w, count = 0;
    while (true) {
        count++;
        f = fis.read();
        w = wis.read();
        if (f == w && w == -1) {
            //end of stream, everything went well.
            return;
        } else if (f == w) {
            //matching up so far
            continue;
        } else {
            //not matching.
            fail("Binary file did not match at byte " + count + ".  Web returned '" + w + "'.  File returned '" + f + "'");
        }


    }
}
 

Code Example 2:

  2 
vote

From project JGlobus, under directory /ssl-proxies/src/main/java/org/globus/gsi/stores/.

Source ResourceProxyCredential.java

protected X509Credential create(GlobusResource globusResource) throws ResourceStoreException {
    InputStream keyInputStream = null;
    InputStream certInputStream = null;
    try {
        keyInputStream = new BufferedInputStream(globusResource.getInputStream());
        certInputStream = new BufferedInputStream(globusResource.getInputStream());
        return new X509Credential(keyInputStream, certInputStream);
    } catch (IOException e) {
        throw new ResourceStoreException(e);
    } catch (CredentialException e) {
        throw new ResourceStoreException(e);
    } finally {

        if (keyInputStream != null) {
            try {
                keyInputStream.close();
            } catch (Exception e) {
                logger.warn("Unable to close stream.");
            }
        }
        if (certInputStream != null) {
            try {
                certInputStream.close();
            } catch (Exception e) {
                logger.warn("Unable to close stream.");
            }
        }
    }
}
 

Code Example 3:

  2 
vote

From project stanbol, under directory /commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/.

Source ManagementUtils.java

public static ArchiveInputStream getArchiveInputStream(String resourceName, InputStream is) throws ArchiveException{
    if(is == null){
        return null;
    }
    if(resourceName != null){
        try {
            return archiveStreamFactory.createArchiveInputStream(resourceName, is);
        } catch (ArchiveException e) {
            //ignore
        }
    }
    return archiveStreamFactory.createArchiveInputStream(new BufferedInputStream(is));
}
 

Code Example 4:

  2 
vote

From project stanbol, under directory /commons/ldpath/clerezza/src/test/java/org/apache/stanbol/commons/ldpath/clerezza/.

Source ClerezzaBackendTest.java

@BeforeClass
public static void readTestData() throws IOException {
    ParsingProvider parser = new JenaParserProvider();
    //NOTE(rw): the new third parameter is the base URI used to resolve relative paths
    graph = new IndexedMGraph();
    InputStream in = ClerezzaBackendTest.class.getClassLoader().getResourceAsStream("testdata.rdf.zip");
    assertNotNull(in);
    ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(in));
    InputStream uncloseable = new UncloseableStream(zipIn);
    ZipEntry entry;
    while((entry = zipIn.getNextEntry()) != null){
        if(entry.getName().endsWith(".rdf")){
            parser.parse(graph,uncloseable, SupportedFormat.RDF_XML,null);
        }
    }
    assertTrue(graph.size() > 0);
    zipIn.close();
    
}
 

Code Example 5:

  1 
vote

From project data-bus, under directory /databus-core/src/main/java/com/inmobi/databus/.

Source FSCheckpointProvider.java

@Override
public byte[] read(String key) {
  Path currentCheckpoint = getCheckpointPath(key);
  BufferedInputStream in=null;
  byte[] buffer = null;
  try {
    LOG.info("checkpoint path:" + currentCheckpoint);
    if (!fs.exists(currentCheckpoint)) {
      LOG.info("No checkpoint to read");
      return null;
    }
    in = new BufferedInputStream(
    fs.open(currentCheckpoint));
    buffer = new byte[in.available()];
    in.read(buffer);
  } catch (IOException e) {
    LOG.warn("Could not read checkpoint ", e);
    throw new RuntimeException(e);
  }
  finally {
    try {
      if (in != null)
        in.close();
    } catch(IOException e) {
      LOG.error("Error in closing [" + currentCheckpoint + "]");
      throw new RuntimeException(e);
    }
  }
  return buffer;
}
 

Code Example 6:

  1 
vote

From project packages_apps_ROMControl, under directory /src/com/koushikdutta/urlimageviewhelper/.

Source DiskLruCache.java

private void readJournal() throws IOException {
    InputStream in = new BufferedInputStream(new FileInputStream(journalFile));
    try {
        String magic = /*Streams.*/readAsciiLine(in);
        String version = /*Streams.*/readAsciiLine(in);
        String appVersionString = /*Streams.*/readAsciiLine(in);
        String valueCountString = /*Streams.*/readAsciiLine(in);
        String blank = /*Streams.*/readAsciiLine(in);
        if (!MAGIC.equals(magic)
                || !VERSION_1.equals(version)
                || !Integer.toString(appVersion).equals(appVersionString)
                || !Integer.toString(valueCount).equals(valueCountString)
                || !"".equals(blank)) {
            throw new IOException("unexpected journal header: ["
                    + magic + ", " + version + ", " + valueCountString + ", " + blank + "]");
        }

        while (true) {
            try {
                readJournalLine(/*Streams.*/readAsciiLine(in));
            } catch (EOFException endOfJournal) {
                break;
            }
        }
    } finally {
        /*IoUtils.*/closeQuietly(in);
    }
}
 

Code Example 7:

  1 
vote

From project jedis, under directory /src/test/java/redis/clients/jedis/tests/.

Source ProtocolTest.java

@Test
public void buildACommand() throws IOException {
    PipedInputStream pis = new PipedInputStream();
    BufferedInputStream bis = new BufferedInputStream(pis);
    PipedOutputStream pos = new PipedOutputStream(pis);
    RedisOutputStream ros = new RedisOutputStream(pos);

    Protocol.sendCommand(ros, Protocol.Command.GET,
            "SOMEKEY".getBytes(Protocol.CHARSET));
    ros.flush();
    pos.close();
    String expectedCommand = "*2\r\n$3\r\nGET\r\n$7\r\nSOMEKEY\r\n";

    int b;
    StringBuilder sb = new StringBuilder();
    while ((b = bis.read()) != -1) {
        sb.append((char) b);
    }

    assertEquals(expectedCommand, sb.toString());
}
 

Code Example 8:

  1 
vote

From project stanbol, under directory /commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/.

Source OWLUtils.java

public static OWLOntologyID guessOntologyID(InputStream content,
                                            Parser parser,
                                            String format,
                                            int limit,
                                            int versionIriOffset) throws IOException {
    long before = System.currentTimeMillis();
    log.info("Guessing ontology ID. Read limit = {} triples; offset = {} triples.", limit,
        versionIriOffset);
    BufferedInputStream bIn = new BufferedInputStream(content);
    bIn.mark(limit * 512); // set an appropriate limit
    OntologyLookaheadMGraph graph = new OntologyLookaheadMGraph(limit, versionIriOffset);
    try {
        parser.parse(graph, bIn, format);
    } catch (RuntimeException e) {}
    OWLOntologyID result;

    if (graph.getOntologyIRI() == null) { // No Ontology ID found
        log.warn(" *** No ontology ID found, ontology has a chance of being anonymous.");
        result = null;
    } else {
        // bIn.reset(); // reset set the stream to the start
        IRI oiri = IRI.create(graph.getOntologyIRI().getUnicodeString());
        result = graph.getVersionIRI() == null ? new OWLOntologyID(oiri) : new OWLOntologyID(oiri,
                IRI.create(graph.getVersionIRI().getUnicodeString()));
        log.info(" *** Guessed ID : {}", result);
    }
    log.info(" ... Triples scanned : {}; filtered in : {}", graph.getScannedTripleCount(), graph.size());
    log.info(" ... Time : {} ms", System.currentTimeMillis() - before);
    return result;
}
 

Code Example 9:

  1 
vote

From project stanbol, under directory /enhancer/engines/metaxa/src/main/java/org/apache/stanbol/enhancer/engines/metaxa/core/.

Source MetaxaCore.java

public Model extract(
        InputStream in, URIImpl docId, String mimeType)
        throws ExtractorException, IOException {

    @SuppressWarnings("rawtypes")
    Set factories = this.extractorRegistry.getExtractorFactories(mimeType);
    Model result = null;
    if (factories != null && !factories.isEmpty()) {
        // get extractor from the first available factory
        ExtractorFactory factory =
            (ExtractorFactory)factories.iterator().next();
        Extractor extractor = factory.get();
        RDFContainerFactory containerFactory =
            new RDFContainerFactoryImpl();
        RDFContainer container =
            containerFactory.getRDFContainer(docId);
        extractor.extract(
            container.getDescribedUri(),
            new BufferedInputStream(in, 8192),
            null, mimeType, container);
        in.close();
        result = container.getModel();
    }

    return result;
}
 

Code Example 10:

  1 
vote

From project stanbol, under directory /enhancer/engines/tika/src/main/java/org/apache/stanbol/enhancer/engines/tika/.

Source TikaEngine.java

private MediaTypeAndStream extractMediaType(ContentItem ci) {
    MediaTypeAndStream mtas = new MediaTypeAndStream();
    mtas.mediaType = getMediaType(ci.getBlob());
    if(mtas.mediaType == null || mtas.mediaType.equals(MediaType.OCTET_STREAM)){
        mtas.in = new BufferedInputStream(ci.getStream());
        try {
            mtas.mediaType = detector.detect(mtas.in, new Metadata());
        } catch (IOException e) {
            log.warn("Exception while detection the MediaType of the" +
                    "parsed ContentItem "+ci.getUri(),e);
            IOUtils.closeQuietly(mtas.in);
            mtas.in = null;
        }
    }
    return mtas;
}
 

Code Example 11:

  1 
vote

From project stanbol, under directory /enhancer/ldpath/src/test/java/org/apache/stanbol/enhancer/ldpath/.

Source ContentItemBackendTest.java

protected static MGraph parseRdfData(ParsingProvider parser,String name) throws IOException {
    MGraph rdfData = new IndexedMGraph();
    InputStream in = getTestResource(name);
    assertNotNull("File '"+name+"' not found",in);
    ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(in));
    InputStream uncloseable = new UncloseableStream(zipIn);
    ZipEntry entry;
    while((entry = zipIn.getNextEntry()) != null){
        if(entry.getName().endsWith(".rdf")){
            parser.parse(rdfData,uncloseable, SupportedFormat.RDF_XML,null);
        }
    }
    assertTrue(rdfData.size() > 0);
    zipIn.close();
    return rdfData;
}
 

Code Example 12:

  1 
vote

From project nuxeo-chemistry, under directory /nuxeo-opencmis-impl/src/main/java/org/nuxeo/ecm/core/opencmis/impl/util/.

Source SimpleImageInfo.java

public SimpleImageInfo(InputStream stream) throws IOException {
    if (stream instanceof BufferedInputStream) {
        in = stream;
    } else {
        in = new BufferedInputStream(stream);
    }
    processStream();
    finishStream();
    stream.close();
}
 

Code Example 13:

  1 
vote

From project aws-sdk-for-android, under directory /src/com/amazonaws/util/.

Source Md5Utils.java

public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException {
    BufferedInputStream bis = new BufferedInputStream(is);
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        byte[] buffer = new byte[16384];
        int bytesRead = -1;
        while ( (bytesRead = bis.read(buffer, 0, buffer.length)) != -1 ) {
            messageDigest.update(buffer, 0, bytesRead);
        }
        return messageDigest.digest();
    } finally {
        try {
            bis.close();
        } catch ( Exception e ) {
            System.err.println("Unable to close input stream of hash candidate: " + e);
        }
    }
}
 

Code Example 14:

  1 
vote

From project aws-sdk-for-android, under directory /src/com/amazonaws/util/.

Source NamespaceRemovingInputStream.java

public NamespaceRemovingInputStream(InputStream in) {
    // Wrap our input stream in a buffered input stream to ensure
    // that it support mark/reset
    super(new BufferedInputStream(in));
}
 

Code Example 15:

  1 
vote

From project java-oss-lib, under directory /src/main/com/trendrr/oss/.

Source WhatsMyIp.java

protected String download(String url) throws IOException {
	  HttpURLConnection sourceConnection = null;
	  BufferedInputStream inputStream = null;
	    URL sourceURL = new URL(url);
	    try {
	    	
	      sourceConnection = (HttpURLConnection)sourceURL.openConnection();
	      sourceConnection.setConnectTimeout(timeout);
	      sourceConnection.setReadTimeout(timeout);
	    }
	    catch (MalformedURLException exc) {
	      throw new RuntimeException("Configured URL caused a MalformedURLException: ", exc);
	    }
	    sourceConnection.connect();
	    inputStream = new BufferedInputStream(sourceConnection.getInputStream());
	    InputStreamReader r = new InputStreamReader(inputStream);
		BufferedReader reader = new BufferedReader(r);
		StringBuilder builder = new StringBuilder();
		String str = "";
		while (str != null) {
			str = reader.readLine();
			if (str != null)
				builder.append(str);
			
		}
	    
	    return builder.toString();
}
 

Code Example 16:

  1 
vote

From project java-oss-lib, under directory /src/main/com/trendrr/oss/.

Source FileHelper.java

public static String zip(String filename) throws Exception{
	int BUFFER = 2048;
	String fname = toSystemDependantFilename(filename);
	BufferedInputStream origin = null;
	FileOutputStream dest = new FileOutputStream(fname + ".zip");
	ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
	//out.setMethod(ZipOutputStream.DEFLATED);
	byte data[] = new byte[BUFFER];
	// get a list of files from current directory
	File in = new File(fname);
	FileInputStream fi = new FileInputStream(in);
	origin = new BufferedInputStream(fi, BUFFER);
	ZipEntry entry = new ZipEntry(in.getName());
	out.putNextEntry(entry);
	int count;
	while((count = origin.read(data, 0, 
			BUFFER)) != -1) {
		out.write(data, 0, count);
	}
	origin.close();

	out.close();
	return fname + ".zip";
}
 

Code Example 17:

  1 
vote

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/tools/.

Source StreamFetcher.java

public URL get(String url) throws MalformedURLException {
	String parsed=null;
	if (url.startsWith("http://")) {
		HttpURLConnection connection=null;
		try {
			URL u = new URL(url);
			connection = (HttpURLConnection)u.openConnection();
			InputStream in = new BufferedInputStream(connection.getInputStream(), 8192);

			byte buffer[]=new byte[8192];
			int read=in.read(buffer);
			if (read<buffer.length) {
				buffer[read]='\0';
			}
			parsed=parse(new String(buffer), handlers);
		} catch (IOException e) {
		} finally {
			if (null!=connection) {
				connection.disconnect();
			}
		}

	}
	return new URL(null==parsed ? url : parsed);
}
 

Code Example 18:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source TokenEmitterTest.java

public void testEmitTokens() throws Exception {
  ByteArrayInputStream stream = new ByteArrayInputStream("{}".getBytes());
  
  TokenEmitter emitter = new TokenEmitter(new BufferedInputStream(stream), new Token[]{
    ConcreteToken.from("{"),
    ConcreteToken.from("}"),
  });
  assertTrue(emitter.hasNext());
  assertEquals(ConcreteToken.from("{"), emitter.next());
  assertTrue(emitter.hasNext());
  assertEquals(ConcreteToken.from("}"), emitter.next());
  assertFalse(emitter.hasNext());
}
 

Code Example 19:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source TokenEmitterTest.java

public void testEmitFallThroughTokens() throws Exception {
  ByteArrayInputStream stream = new ByteArrayInputStream("foo,bar,foo}".getBytes());
  
  TokenEmitter emitter = new TokenEmitter(new BufferedInputStream(stream), new Token[]{
    ConcreteToken.from("}"),
  });
  assertTrue(emitter.hasNext());
  assertEquals(ConcreteToken.from("foo,bar,foo"), emitter.next());
  assertTrue(emitter.hasNext());
  assertEquals(ConcreteToken.from("}"), emitter.next());
  assertFalse(emitter.hasNext());
}
 

Code Example 20:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source HtmlDocLexerTest.java

public void testCreateTokens() throws Exception {
  List<Token> expected = Lists.newArrayList(tokens[0],
    tokens[1], tokens[2], tokens[3]);
  BufferedInputStream stream =
      new BufferedInputStream(
          new ByteArrayInputStream((tokens[0].toString()
                                    + tokens[1].toString()
                                    + tokens[2].toString()
                                    + tokens[3].toString()).getBytes()));
  BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
  for (Token token : expected) {
    assertEquals(token, lexer.read());
  }
  assertFalse(lexer.available());
}
 

Code Example 21:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source HtmlDocLexerTest.java

public void testCreateTokensWithOtherTokens() throws Exception {
  Token otherOne = new ConcreteToken("<div></div>".toCharArray());
  BufferedInputStream stream =
    new BufferedInputStream(
      new ByteArrayInputStream((tokens[0].toString()
          + otherOne.toString() + tokens[1].toString()).getBytes()));

  BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
  List<Token> expected =
      Lists.newArrayList(tokens[0], otherOne, tokens[1]);
  for (Token token : expected) {
    assertEquals(token, lexer.read());
  }
}
 

Code Example 22:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source HtmlDocLexerTest.java

public void testCreateTokensFromRealCode() throws Exception {
  BufferedInputStream stream = new BufferedInputStream(
      new ByteArrayInputStream(("TestCase.prototype.setUp = function(){"
                                + "  this.foo = 1;"
                                + "  /*:DOC bar = <div></div>*/"
                                + "};").getBytes()));
  
  BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
  List<Token> expected = Lists.newArrayList(
    ConcreteToken.from("TestCase.prototype.setUp "),
    ConcreteToken.from("="),
    ConcreteToken.from(" function()"),
    ConcreteToken.from("{"),
    ConcreteToken.from("  this.foo "),
    tokens[3],
    ConcreteToken.from(" 1;  "),
    tokens[0],
    ConcreteToken.from(" bar "),
    ConcreteToken.from("="),
    ConcreteToken.from(" <div></div>"),
    tokens[1],
    tokens[4]);
  for (Token token : expected) {
    assertEquals(token, lexer.read());
  }
}
 

Code Example 23:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src-test/com/google/jstestdriver/html/.

Source HtmlDocLexerTest.java

public void testCreateTokensWithCommentTokens() throws Exception {
  Token otherOne = new ConcreteToken("/** foo".toCharArray());
  BufferedInputStream stream =
    new BufferedInputStream(
      new ByteArrayInputStream((tokens[2].toString()
          + otherOne.toString() + tokens[1].toString() + tokens[3].toString()).getBytes()));
  
  BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
  List<Token> expected =
    Lists.newArrayList(tokens[2], otherOne, tokens[1], tokens[3]);
  for (Token token : expected) {
    assertEquals(token, lexer.read());
  }
}
 

Code Example 24:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src/com/google/jstestdriver/token/.

Source ConcreteToken.java

public Token create(BufferedInputStream stream) {
  try {
    for (int i = 0; i < token.length; i++) {
      char read = (char) stream.read();
      if (token[i] != read) {
        stream.reset();
        return null;
      }
    }
    stream.mark(Integer.MAX_VALUE);
    return this;
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 

Code Example 25:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src/com/google/jstestdriver/.

Source SimpleFileReader.java

public String readFile(String file)  {
  InputStreamReader reader = null;
  try {
    reader = new InputStreamReader(new BufferedInputStream(new FileInputStream(file)), Charset.forName("UTF-8"));
    StringBuilder sb = new StringBuilder();

    for (int c = reader.read(); c != -1; c = reader.read()) {
      sb.append((char) c);
    }
    String contents = sb.toString();

    return contents;
  } catch (IOException e) {
    throw new RuntimeException("Impossible to read file: " + file, e);
  } finally {
    if (reader != null) {
      try {
        reader.close();
      } catch (IOException e) {
        // ignore
      }
    }
  }
}
 

Code Example 26:

  1 
vote

From project JsTestDriver, under directory /JsTestDriver/src/com/google/jstestdriver/coverage/.

Source ClassFileLoader.java

public String load(String path) {
  InputStream resourceStream =
      new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(path));
  StringBuilder sb = new StringBuilder();

  try {
    for (int c = resourceStream.read(); c != -1; c = resourceStream.read()) {
      sb.append((char) c);
    }
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  return sb.toString();
}
 

Code Example 27:

  1 
vote

From project GeniusWiki, under directory /src/wiki/java/com/edgenius/wiki/webapp/action/.

Source BaseAction.java

protected void downloadFile(String name, File dFile) {
	HttpServletResponse response = getResponse();
	response.setContentType("application/octet-stream");
	response.setHeader("Content-Disposition", "attachment;filename=\"" + name + "\"");
	response.setHeader("Cache-control", "must-revalidate");
	response.addHeader("Content-Description", name);

	InputStream in = null;
	try {
		in = new BufferedInputStream(new FileInputStream(dFile));
		OutputStream out = response.getOutputStream();
		int count = 0;

		int len=0;
		byte[] ch = new byte[10240];
		while ((len = in.read(ch)) != -1) {
			out.write(ch,0,len);
			count +=len;
		}
		response.setContentLength(count);
	} catch (IOException e) {
		log.error("Exception occured writing out file:" + name,e);
	} finally {
		try {
			if (in != null)
				in.close(); // very important
		} catch (IOException e) {
			log.error("Error Closing file. File already written out - no exception being thrown.", e);
		}
	}
}
 

Code Example 28:

  1 
vote

From project GeniusWiki, under directory /src/core/java/com/edgenius/core/util/.

Source ZipFileUtil.java

private static void addEntry(ZipOutputStream zop, File entry, String entryName) throws IOException{
if(StringUtils.isBlank(entryName))
	return;
		
BufferedInputStream source = null;
if(entry != null){
	source = new BufferedInputStream(new FileInputStream(entry));
}else{
	//to make this as directory
	if(!entryName.endsWith("/"))
		entryName += "/";
}
  	ZipEntry zipEntry = new ZipEntry(entryName);
zop.putNextEntry(zipEntry);
		
if(entry != null){
	//transfer bytes from file to ZIP file
	byte[] data = new byte[ BUFFER_SIZE ];
	int length;
	while((length = source.read(data)) > 0){
		zop.write(data, 0, length);
	}
   	IOUtils.closeQuietly(source);
}
zop.closeEntry();
		
  }
 

Code Example 29:

  1 
vote

From project PlayerStatusSigns, under directory /src/main/java/com/nuclearw/pss/.

Source Pss.java

public String readVersion() {
	byte[] buffer = new byte[(int) versionFile.length()];
	BufferedInputStream f = null;
	try {
		f = new BufferedInputStream(new FileInputStream(versionFile));
		f.read(buffer);
	} catch (FileNotFoundException ex) {
		ex.printStackTrace();
	} catch (IOException ex) {
		ex.printStackTrace();
	} finally {
		if (f != null) try { f.close(); } catch (IOException ignored) { }
	}

	return new String(buffer);
}
 

Code Example 30:

  1 
vote

From project groovejaar, under directory /src/jaco/mp3/resources/.

Source SoundStream.java

public SoundStream(InputStream in)
{
	if (in==null) throw new NullPointerException("in");
	in = new BufferedInputStream(in);		
	loadID3v2(in);
	firstframe = true;
	//source = new PushbackInputStream(in, 1024);
	source = new PushbackInputStream(in, BUFFER_INT_SIZE*4);
	
	closeFrame();
	//current_frame_number = -1;
	//last_frame_number = -1;
}
 

Code Example 31:

  1 
vote

From project S-Space, under directory /src/main/java/edu/ucla/sspace/graph/io/.

Source GraphMLReader.java

public WeightedDirectedMultigraph<String> readWeightedDirectedMultigraph(
        File f, Indexer<String> vertexLabels) throws IOException {        
    try {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        ParserAdapter pa = new ParserAdapter(sp.getParser());
        
        GraphMLParser parser = new GraphMLParser(vertexLabels);
        
        pa.setContentHandler(parser);
        pa.setErrorHandler(parser);
        pa.parse(new InputSource(new BufferedInputStream(new FileInputStream(f))));
        return parser.g;
    } catch (SAXException saxe) {
        throw new IOException(saxe);
    } catch (ParserConfigurationException saxe) {
        throw new IOException(saxe);
    }
}