FileInputStream close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FileInputStream close method.

This code example shows how to use the following methods:close
            throw new IllegalArgumentException("Missing VM parameter cqs.stresstest.propertyFile");
        } 
 
		try { 
 
			FileInputStream fileStream = new FileInputStream(file);
			props.load(fileStream);
 
            testDurationSeconds = Integer.parseInt(props.getProperty("cmb.cqs.stress.testDurationSeconds", "100"));
            messagesPerQueuePerSecond = Integer.parseInt(props.getProperty("cmb.cqs.stress.messagesPerQueuePerSecond", "100"));
            numberOfQueues = Integer.parseInt(props.getProperty("cmb.cqs.stress.numberOfQueues", "5"));
            numberOfSendersPerQueue = Integer.parseInt(props.getProperty("cmb.cqs.stress.numberOfSendersPerQueue", "4"));
            numberOfReceiversPerQueue = Integer.parseInt(props.getProperty("cmb.cqs.stress.numberOfReceiversPerQueue", "15"));
            sendMessageBatchSize = Integer.parseInt(props.getProperty("cmb.cqs.stress.sendMessageBatchSize", "1"));
            receiveMessageBatchSize = Integer.parseInt(props.getProperty("cmb.cqs.stress.receiveMessageBatchSize", "1"));
            delayBetweenSendsMS = Integer.parseInt(props.getProperty("cmb.cqs.stress.delayBetweenSendsMS", "0"));
            delayBetweenReceivesMS = Integer.parseInt(props.getProperty("cmb.cqs.stress.delayBetweenReceivesMS", "5"));
            delayBetweenReceiveAndDeleteMS = Integer.parseInt(props.getProperty("cmb.cqs.stress.delayBetweenReceiveAndDeleteMS", "40"));
            revisiblePercentage = Integer.parseInt(props.getProperty("cmb.cqs.stress.revisiblePercentage", "0"));
 

8
CodeRank
This code example shows how to use the following methods:close
			windowPositions = new Properties();
 
			FileInputStream in = null;
 
			try { 
				in = new FileInputStream(FileUtil.getWindowConfigFile());
				windowPositions.load(in);
			} catch (FileNotFoundException e) {
				Logger.logMessage("Creating " + FileUtil.getWindowConfigFile().getName() + " file"); 
			} catch (Exception e) {
				Logger.logError(e);
			} finally { 
				if (in != null) {
					try { 
						in.close();
					} catch (IOException ignored) {}
				} 
			} 
		} 
		return windowPositions;
8
CodeRank
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
This code example shows how to use the following methods:close
            writer = new RIFFWriter(tempfile, "TEST");
            RIFFWriter chunk = writer.writeChunk("TSCH");
            chunk.writeByte(10);
            writer.close();
            writer = null;
            FileInputStream fis = new FileInputStream(tempfile);
            reader = new RIFFReader(fis);
            RIFFReader readchunk = reader.nextChunk();
            int avail = readchunk.available();
            readchunk.readByte();
            assertEquals(avail - 1,readchunk.available());
            fis.close();
            reader = null;
 
 
        } 
        finally 
        { 
            if(writer != null)
                writer.close();
8
CodeRank
This code example shows how to use the following methods:decodeStream, close
	 */ 
	public static Bitmap getBitmapByFile(File file) {
		FileInputStream fis = null;
		Bitmap bitmap =null; 
		try {  
			fis = new FileInputStream(file);
			bitmap = BitmapFactory.decodeStream(fis);
		} catch (FileNotFoundException e) {  
			e.printStackTrace();
		} catch (OutOfMemoryError e) {
			e.printStackTrace();
		} finally{ 
			try { 
				fis.close();
			} catch (Exception e) {}
		} 
		return bitmap;
	} 
	 
	/** 
7
CodeRank
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
This code example shows how to use the following methods:close
            writer = new RIFFWriter(tempfile, "TEST");
            RIFFWriter chunk = writer.writeChunk("TSCH");
            chunk.writeUnsignedByte(77);
            writer.close();
            writer = null;
            FileInputStream fis = new FileInputStream(tempfile);
            reader = new RIFFReader(fis);
            assertEquals(reader.getFormat(), "RIFF");
            assertEquals(reader.getType(), "TEST");
            RIFFReader readchunk = reader.nextChunk();
            assertEquals(readchunk.getFormat(), "TSCH");
            assertEquals(reader.readUnsignedByte(), 77);
            fis.close();
            reader = null;
 
 
        } 
        finally 
        { 
            if(writer != null)
8
CodeRank
This code example shows how to use the following methods:close
		try { 
			flush(); 
			close(); 
 
			if (_fis != null) {
				_fis.close();
			} 
 
			FileUtil.delete(_tempFile);
		} 
		catch (IOException ioe) {
			if (_log.isWarnEnabled()) {
				_log.warn(ioe.getMessage());
			} 
		} 
	} 
 
	@Override 
	public void close() throws IOException {
		_ubos.close();
7
CodeRank
This code example shows how to use the following methods:close, read
    public static void main(String args[]) throws Exception {
 
        // read the (TCP) port number from the given file 
 
        File f = new File(args[0]);
        FileInputStream fis = new FileInputStream(f);
        byte b[] = new byte[8];
        int n = fis.read(b);
        if (n < 1) {
            throw new RuntimeException("Empty file");
        } 
        fis.close();
 
        String str = new String(b, 0, n, "UTF-8");
        System.out.println("Port number of debuggee is: " + str);
        int port = Integer.parseInt(str);
 
        // Now connect to the port (which will shutdown debuggee) 
 
        System.out.println("Connecting to port " + port +
7
CodeRank
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

Related FileInputStream close Questions & Answers:

close Method Overview
Closes this file input stream and releases any system resources associated with the stream.
See Code Examples for other Java 8 FileInputStream Methods: