Java 8 FileInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FileInputStream class.

This code example shows how to use the following methods:
        Properties props = new Properties();
 
        File file = new File(getUserHome(), JLINE_RC);
        if (file.exists() && file.canRead()) {
            try { 
                InputStream input = new BufferedInputStream(new FileInputStream(file));
                try { 
                    props.load(input);
                    Log.debug("Loaded user configuration: ", file);
                } 
                finally { 
                    input.close();
                } 
            } 
            catch (IOException e) {
                Log.warn("Unable to read user configuration: ", file, e);
            } 
        } 
        else { 
            Log.trace("User configuration file missing or unreadable: ", file);
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
	  FileInputStream fis = null;
	  // 
	  // Parse the Properties file 
	  // 
	  try { 
		  fis = new FileInputStream(new File(fileName));
		  m_properties.load(fis);
	  } 
	  finally 
	  { 
		  if( fis != null) {
        fis.close();
      } 
	  } 
  } 
 
  /** 
   * Returns the properties loaded. 
   * @return loaded properties. 
   */ 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
   * be recovered (especially on Windows) on datanode restart. 
   */ 
  private void unlinkFile(File file, Block b) throws IOException {
    File tmpFile = DatanodeUtil.createTmpFile(b, DatanodeUtil.getUnlinkTmpFile(file));
    try { 
      FileInputStream in = new FileInputStream(file);
      try { 
        FileOutputStream out = new FileOutputStream(tmpFile);
        try { 
          IOUtils.copyBytes(in, out, 16*1024);
        } finally { 
          out.close();
        } 
      } finally { 
        in.close();
      } 
      if (file.length() != tmpFile.length()) {
        throw new IOException("Copy of file " + file + " size " + file.length()+
                              " into file " + tmpFile +
                              " resulted in a size of " + tmpFile.length());
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        return IO.readContent(defaultFile);
    } 
 
    public InputStream asStream() {
        try { 
            return new FileInputStream(defaultFile);
        } catch (IOException ex) {
            throw new UnexpectedException(ex);
        } 
    } 
     
    public String getContentType() {
        return fileItem.getContentType();
    } 
 
    public String getFileName() {
        return fileItem.getName();
    } 
 
    public String getFieldName() {
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:available, close, read
 
	byte[] read(String hash) {
		byte[] value;
		FileInputStream inputStream;
		try { 
			inputStream = new FileInputStream(getFile(hash));
			value = new byte[inputStream.available()];
			inputStream.read(value);
			inputStream.close();
		} catch (FileNotFoundException e) {
			value = null;
		} catch (IOException e) {
			value = null;
		} 
		return value;
	} 
 
	void write(String hash, byte[] value) {
		try { 
			FileOutputStream outputStream = new FileOutputStream(getFile(hash));
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, read, skip
        int    nOffset = 0;
        int nBufSize = 0;
 
        if ((column == 1) && (theFile != null)) {
            try { 
                FileInputStream fin = new FileInputStream(theFile);
                nOffset = row * BUFSIZE;
                if (row < (nCount - 1)) {
                    nBufSize = BUFSIZE;
                } else { 
                    nBufSize = (int) (lFileSize - nOffset);
                } 
                theBuffer = new byte[nBufSize];
 
                if (theBuffer != null) {
                    if (fin.skip(nOffset + lOffset) == (nOffset + lOffset)) {
                        if ((nRead = fin.read(theBuffer, 0, nBufSize)) != -1) {
                            if (nRead != nBufSize) {
                                return null; 
                            } 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
        if (!propertiesFile.exists()) return null;
 
        Properties properties = new Properties();
        FileInputStream stream;
        try { 
            stream = new FileInputStream(propertiesFile);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } 
 
        try { 
            try { 
                properties.load(stream);
            } finally { 
                stream.close();
            } 
        } catch (IOException e) {
            throw new RuntimeException(e);
        } 
        return properties;
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            } 
        } finally { 
            IOUtils.close(randomAccessFile);
        } 
 
        XContentParser parser = YamlXContent.yamlXContent.createParser(new FileInputStream(file));
        try { 
            RestTestSuiteParseContext testParseContext = new RestTestSuiteParseContext(api, filename, parser);
            return parse(testParseContext);
        } catch(Exception e) {
            throw new RestTestParseException("Error parsing " + api + "/" + filename, e);
        } finally { 
            parser.close();
        } 
    } 
 
    @Override 
    public RestTestSuite parse(RestTestSuiteParseContext parseContext) throws IOException, RestTestParseException {
        XContentParser parser = parseContext.parser();
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
    return file;
  } 
 
  public void load() { 
    try { 
      InputStream stream = new FileInputStream(getFile());
      try { 
        properties.load(stream);
      } finally { 
        stream.close();
      } 
    } catch (FileNotFoundException e) {
      save(); 
    } catch (IOException e) {
      properties.clear();
      populate(); 
      save(); 
    } 
  } 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, read
    private boolean checkIfEmpty(File file) throws Exception {
        boolean empty = false;
        FileInputStream fis = null;
        assertTrue(file.exists());
        try { 
            fis = new FileInputStream(file);
            empty = fis.read() == -1;
        } finally { 
            if (fis != null) {
                fis.close();
            } 
        } 
        return empty;
    } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 FileInputStream Questions & Answers:

Other Java 8 FileInputStream Examples

100:				BitmapFactory.Options o = new BitmapFactory.Options();
101:				o.inJustDecodeBounds = true;
102:				BitmapFactory.decodeStream(new FileInputStream(f), null, o);
103:	
104:				final int REQUIRED_WIDTH = WIDTH;
-
111:				BitmapFactory.Options o2 = new BitmapFactory.Options();
112:				o2.inSampleSize = scale;
113:				return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
114:			} catch (FileNotFoundException e) {
115:				e.printStackTrace();

Read More

87:	            o.inJustDecodeBounds = true;
88:	            BitmapFactory.decodeStream(new FileInputStream(f),null,o);
89:	
90:	            //Find the correct scale value. It should be the power of 2.
91:	            final int REQUIRED_SIZE=70;
-
104:	            o2.inSampleSize=scale;
105:	            return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
106:	        } catch (FileNotFoundException e) {}
107:	        return null;
108:	    }

Read More

88:	            BitmapFactory.Options o = new BitmapFactory.Options();
89:	            o.inJustDecodeBounds = true;
90:	            BitmapFactory.decodeStream(new FileInputStream(f),null,o);
91:	 
92:	            //Find the correct scale value. It should be the power of 2.

Read More

See Code Examples for Java 8 FileInputStream Methods: