当前位置: 首页>>代码示例>>Java>>正文


Java FileInputStream.close方法代码示例

本文整理汇总了Java中java.io.FileInputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java FileInputStream.close方法的具体用法?Java FileInputStream.close怎么用?Java FileInputStream.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.FileInputStream的用法示例。


在下文中一共展示了FileInputStream.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fileCombination

import java.io.FileInputStream; //导入方法依赖的package包/类
public static void fileCombination(File file, String targetFile) throws Exception {
	outFile = new File(targetFile);	
	outDest = new RandomAccessFile(outFile,"rw");     
	childReader = new BufferedReader(new FileReader(file));
	long temp = 0;
	while ((name = childReader.readLine()) != null) {
		cFile = new File(name);
		long size = cFile.length();
		fileReader = new FileInputStream(cFile);	
		read = fileReader.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, size); 
		out = outDest.getChannel().map(FileChannel.MapMode.READ_WRITE, temp, size); 	
		temp += size; 
		for (long j = 0; j < size; j++) {  
	         byte b = read.get();    
	         out.put(b);               
	    }  	
	    fileReader.close();
		UnMap.unmap(read);
		UnMap.unmap(out);
	}			
	outDest.close();      
	childReader.close();
}
 
开发者ID:lslxy1021,项目名称:FileOperation,代码行数:24,代码来源:NIOMerge.java

示例2: ReadDIASettingSerialization

import java.io.FileInputStream; //导入方法依赖的package包/类
public static DIA_Setting ReadDIASettingSerialization(String filepath) {
    if (!new File(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_diasetting.ser").exists()) {
        return null;
    }
    try {
        Logger.getRootLogger().debug("Reading DIA setting from file:" + FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_diasetting.ser...");

        FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + "_diasetting.ser");
        ObjectInputStream in = new ObjectInputStream(fileIn);
        DIA_Setting setting = (DIA_Setting) in.readObject();
        in.close();
        fileIn.close();
        return setting;

    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return null;
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:20,代码来源:DIA_Setting.java

示例3: copyToAndroidData

import java.io.FileInputStream; //导入方法依赖的package包/类
private void copyToAndroidData(String sourcePath, String destPath) {
    Log.i("nib", "dest: " + destPath + "\n" + "source:" + sourcePath);
    try {
        FileInputStream inputStream = new FileInputStream(new File(sourcePath));
        FileOutputStream outputStream = new FileOutputStream(new File(destPath));
        byte bt[] = new byte[1024];
        int c;
        while ((c = inputStream.read(bt)) > 0) {
            outputStream.write(bt, 0, c);
        }
        inputStream.close();
        outputStream.close();
        ToastUtil.showShort(R.string.save_success);
        btnSaveToLocal.setClickable(false);
        Log.i("nib", "复制完成");
    } catch (Exception e) {
        Log.i("nib", e.toString());
    }
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:20,代码来源:PlayListenActivity.java

示例4: zipIt

import java.io.FileInputStream; //导入方法依赖的package包/类
/**
 * Zip it
 */
public void zipIt(){
    byte[] buffer = new byte[1024];
    try{
        FileOutputStream fos = new FileOutputStream(OUTPUT_ZIP_FILE);
        ZipOutputStream zos = new ZipOutputStream(fos);
        //System.out.println("Output to Zip : " + zipFile);
        for(String file : this.fileList){
            //System.out.println("File Added : " + file);
            ZipEntry ze= new ZipEntry(file);
            zos.putNextEntry(ze);
            FileInputStream in = new FileInputStream(SOURCE_FOLDER.getAbsolutePath() + File.separator + file);
            int len;
            while ((len = in.read(buffer)) > 0) {
                zos.write(buffer, 0, len);
            }
            in.close();
       }
       zos.closeEntry();
       zos.close();
       //System.out.println("Done");
    } catch (IOException ex) {
        ex.printStackTrace();   
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:28,代码来源:JAppZip.java

示例5: fileTxtRead

import java.io.FileInputStream; //导入方法依赖的package包/类
String fileTxtRead(String fileName)
{  
	String res="";
       try
	{
		File file = new File(fileName);  
		FileInputStream fis = new FileInputStream(file);  
		int length = fis.available(); 
		byte [] buffer = new byte[length]; 
		fis.read(buffer);     
		res = EncodingUtils.getString(buffer, "UTF-8"); 
		fis.close();     
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}  
	return res;
}
 
开发者ID:nijigenirubasho,项目名称:mobiletailchanger,代码行数:20,代码来源:MainActivity.java

示例6: loadBinary

import java.io.FileInputStream; //导入方法依赖的package包/类
/**
 * Binary file load
 */
static public byte[] loadBinary(File binFile) throws IOException {
    byte[]                xferBuffer = new byte[10240];
    ByteArrayOutputStream baos       = new ByteArrayOutputStream();
    int                   i;
    FileInputStream       fis        = new FileInputStream(binFile);

    try {
        while ((i = fis.read(xferBuffer)) > 0) {
            baos.write(xferBuffer, 0, i);
        }
    } finally {
        fis.close();
    }

    byte[] ba = baos.toByteArray();

    return ba;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:SqlFile.java

示例7: copyFiles

import java.io.FileInputStream; //导入方法依赖的package包/类
private void copyFiles(File from, File to) throws IOException {
    LOG.fine("Copy " + from + " to " + to);
    if (from.isDirectory()) {
        to.mkdirs();
        for (File f : from.listFiles()) {
            copyFiles(f, new File(to, f.getName()));
        }
    } else {
        byte[] arr = new byte[4096];
        FileInputStream is = new FileInputStream(from);
        FileOutputStream os = new FileOutputStream(to);
        for (;;) {
            int r = is.read(arr);
            if (r == -1) {
                break;
            }
            os.write(arr, 0, r);
        }
        is.close();
        os.close();
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GenerateJNLPApplicationTest.java

示例8: testDataWriting

import java.io.FileInputStream; //导入方法依赖的package包/类
@Test
public void testDataWriting() throws Exception {
  long byteAm = 100;
  File fn = getTestFile();
  DataWriter writer = new DataWriter(rnd);
  FileOutputStream fs = new FileOutputStream(fn);
  GenerateOutput ostat = writer.writeSegment(byteAm, fs);
  LOG.info(ostat);
  fs.close();
  assertTrue(ostat.getBytesWritten() == byteAm);
  DataVerifier vf = new DataVerifier();
  FileInputStream fin = new FileInputStream(fn);
  VerifyOutput vfout = vf.verifyFile(byteAm, new DataInputStream(fin));
  LOG.info(vfout);
  fin.close();
  assertEquals(vfout.getBytesRead(), byteAm);
  assertTrue(vfout.getChunksDifferent() == 0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestSlive.java

示例9: addFileToZip

import java.io.FileInputStream; //导入方法依赖的package包/类
static private void addFileToZip(String path, String srcFile, ZipOutputStream zip)
        throws Exception {
    File folder = new File(srcFile);
    if (folder.isDirectory()) {
        addFolderToZip(path, srcFile, zip);
    } else {

        byte[] buf = new byte[1024];
        int len;
        FileInputStream in = new FileInputStream(srcFile);
        zip.putNextEntry(new ZipEntry(path + "/" + folder.getName()));
        while ((len = in.read(buf)) > 0) {
            zip.write(buf, 0, len);
        }
        in.close();

    }
}
 
开发者ID:cybershrapnel,项目名称:nanocheeze,代码行数:19,代码来源:Torrent2.java

示例10: restoreFromCache

import java.io.FileInputStream; //导入方法依赖的package包/类
public Bitmap restoreFromCache(Card card, Cache cache) throws IOException {
    String fileName = cache.getCacheLocation(getFileName(card));
    FileInputStream in = context.openFileInput(fileName);
    Bitmap out = BitmapFactory.decodeStream(in);
    in.close();
    return out;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:8,代码来源:CacheManager.java

示例11: parseFile

import java.io.FileInputStream; //导入方法依赖的package包/类
/**
 * Parse the given configuration file
 * 
 * @param configFile
 *            EncFS volume configuration file.
 * @return An EncFSConfig object containing the configuration data
 *         interpreted from the given file.
 */
public static EncFSConfig parseFile(File configFile)
		throws ParserConfigurationException, SAXException, IOException,
		EncFSInvalidConfigException, EncFSUnsupportedException {
	FileInputStream inputStream = new FileInputStream(configFile);
	try {
		return parseFile(inputStream);
	} finally {
		inputStream.close();
	}

}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:20,代码来源:EncFSConfigParser.java

示例12: load

import java.io.FileInputStream; //导入方法依赖的package包/类
public static Player load(String playerName) throws IOException, ClassNotFoundException {
	String filename = playerName + ".player";
	Player player = null;
       FileInputStream fileIn = new FileInputStream(filename);
       ObjectInputStream in = new ObjectInputStream(fileIn);
       player = (Player) in.readObject();
       in.close();
       fileIn.close();
       logger.info("Loaded Player definition file from `" + filename + "`");
       return player;
}
 
开发者ID:Azure,项目名称:acs-demos,代码行数:12,代码来源:Player.java

示例13: getAudioFileFormat

import java.io.FileInputStream; //导入方法依赖的package包/类
/**
 * Obtains the audio file format of the File provided.  The File must
 * point to valid audio file data.
 *
 * @param file the File from which file format information should be
 *             extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the File does not point to valid audio
 *                                       file data recognized by the system
 * @throws IOException                   if an I/O exception occurs
 */
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
    AudioFileFormat fileFormat = null;
    FileInputStream fis = new FileInputStream(file);       // throws IOException
    // part of fix for 4325421
    try {
        fileFormat = getFMT(fis, false);
    } finally {
        fis.close();
    }

    return fileFormat;
}
 
开发者ID:souhaib100,项目名称:MARF-for-Android,代码行数:24,代码来源:WaveFileReader.java

示例14: getEditorInput

import java.io.FileInputStream; //导入方法依赖的package包/类
/**
 * Generate Container from xml,Setting FileStorageEditor Input into Ifile
 * @return Container
 * @throws IOException
 */
@Override
public Container getEditorInput() throws IOException {
	logger.debug("storeEditorInput - Setting FileStorageEditor Input into Ifile");
	Container con = null;
	File file = new File(fileStorageEditorInput.getToolTipText());
	FileInputStream fs = new FileInputStream(file);
	con = (Container) CanvasUtils.INSTANCE.fromXMLToObject(fs);
	this.eltGraphicalEditorInstance.setPartName(file.getName());
	fs.close();
	return con;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:FileStorageEditorContainer.java

示例15: WriteFile

import java.io.FileInputStream; //导入方法依赖的package包/类
public void WriteFile(File outputFile, int startFrame, int numFrames)
        throws java.io.IOException {
    outputFile.createNewFile();
    FileInputStream in = new FileInputStream(mInputFile);
    FileOutputStream out = new FileOutputStream(outputFile);

    byte[] header = new byte[6];
    header[0] = '#';
    header[1] = '!';
    header[2] = 'A';
    header[3] = 'M';
    header[4] = 'R';
    header[5] = '\n';
    out.write(header, 0, 6);

    int maxFrameLen = 0;
    for (int i = 0; i < numFrames; i++) {
        if (mFrameLens[startFrame + i] > maxFrameLen)
            maxFrameLen = mFrameLens[startFrame + i];
    }
    byte[] buffer = new byte[maxFrameLen];
    int pos = 0;
    for (int i = 0; i < numFrames; i++) {
        int skip = mFrameOffsets[startFrame + i] - pos;
        int len = mFrameLens[startFrame + i];
        if (skip < 0) {
            continue;
        }
        if (skip > 0) {
            in.skip(skip);
            pos += skip;
        }
        in.read(buffer, 0, len);
        out.write(buffer, 0, len);
        pos += len;
    }

    in.close();
    out.close();
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:41,代码来源:CheapAMR.java


注:本文中的java.io.FileInputStream.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。