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


Java IOUtils.closeStream方法代码示例

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


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

示例1: loadLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static LocalStructureJiang [][] loadLSMapFile(Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
    	MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
    	
    	LocalStructureJiang [][] result = null;

		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		LSJiangArray value = (LSJiangArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
		
		try {
			while(lsmapfile.next(key, value)) {
				result = (LocalStructureJiang [][]) ArrayUtils.add(result,
						Arrays.copyOf(value.get(), value.get().length, LocalStructureJiang[].class));
			}
		} catch (Exception e) {
			System.err.println("LocalStructureJiang.loadLSMapFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}
		
		IOUtils.closeStream(lsmapfile);
		
		return result;		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:27,代码来源:LocalStructureJiang.java

示例2: loadInfoFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public Map<String, Integer> loadInfoFile(Configuration conf) {

		String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
		MapFile.Reader infofile = Util.createMapFileReader(conf, name);

		Map<String, Integer> infomap = new HashMap<String,Integer>();

		Text key = new Text();
		IntWritable value = new IntWritable();

		try {
			while(infofile.next(key, value)) {
				infomap.put(key.toString(), value.get());
			}
		} catch (Exception e) {
			System.err.println("PartialScoreCylinder.loadInfoFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}

		IOUtils.closeStream(infofile);

		return infomap;
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:25,代码来源:PartialScoreLSS.java

示例3: loadInfoFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static Map<String, Minutia[]> loadInfoFile(Configuration conf) {

		Map<String, Minutia[]> infomap = new HashMap<String, Minutia[]>();

		String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
		MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);

		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		MinutiaArray value = (MinutiaArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);

		try {
			while(lsmapfile.next(key, value)) {
				Writable [] w = value.get();
				infomap.put(key.toString(), Arrays.copyOf(w, w.length, Minutia[].class));
			}
		} catch (Exception e) {
			System.err.println("PartialScoreLSSR.loadInfoFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}

		IOUtils.closeStream(lsmapfile);

		return infomap;
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:27,代码来源:PartialScoreLSSRImproved.java

示例4: loadLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static LocalStructureCylinder [][] loadLSMapFile(Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
		MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);

		LocalStructureCylinder [][] result = null;

		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		LSCylinderArray value = (LSCylinderArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);

		try {
			while(lsmapfile.next(key, value)) {
				result = (LocalStructureCylinder [][]) ArrayUtils.add(result,
						Arrays.copyOf(value.get(), value.get().length, LocalStructureCylinder[].class));
			}
		} catch (Exception e) {
			System.err.println("LocalStructureCylinder.loadLSMapFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}

		IOUtils.closeStream(lsmapfile);

		return result;		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:27,代码来源:PartialScoreLSSRImproved.java

示例5: loadLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static LocalStructureCylinder [][] loadLSMapFile(Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
    	MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
    	
    	LocalStructureCylinder [][] result = null;

		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		LSCylinderArray value = (LSCylinderArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
		
		try {
			while(lsmapfile.next(key, value)) {
				result = (LocalStructureCylinder [][]) ArrayUtils.add(result,
						Arrays.copyOf(value.get(), value.get().length, LocalStructureCylinder[].class));
			}
		} catch (Exception e) {
			System.err.println("LocalStructureCylinder.loadLSMapFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}
		
		IOUtils.closeStream(lsmapfile);
		
		return result;		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:27,代码来源:LocalStructureCylinder.java

示例6: loadInfoFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static Map<String, Minutia[]> loadInfoFile(Configuration conf) {

		Map<String, Minutia[]> infomap = new HashMap<String, Minutia[]>();

		String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);
		MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);

		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		MinutiaArray value = (MinutiaArray) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);

		try {
			while(lsmapfile.next(key, value)) {
				infomap.put(key.toString(), Arrays.copyOf(value.get(), value.get().length, Minutia[].class));
			}
		} catch (Exception e) {
			System.err.println("PartialScoreLSSR.loadInfoFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}

		IOUtils.closeStream(lsmapfile);

		return infomap;
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:26,代码来源:PartialScoreLSSR.java

示例7: writeJobSplitMetaInfo

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
private static void writeJobSplitMetaInfo(FileSystem fs, Path filename, FsPermission p, int splitMetaInfoVersion,
        JobSplit.SplitMetaInfo[] allSplitMetaInfo) throws IOException {
    // write the splits meta-info to a file for the job tracker
    FSDataOutputStream out = null;
    try {
        out = FileSystem.create(fs, filename, p);
        out.write(META_SPLIT_FILE_HEADER);
        WritableUtils.writeVInt(out, splitMetaInfoVersion);
        WritableUtils.writeVInt(out, allSplitMetaInfo.length);
        for(JobSplit.SplitMetaInfo splitMetaInfo: allSplitMetaInfo) {
            splitMetaInfo.write(out);
        }
    } finally {
        IOUtils.closeStream(out);
    }
}
 
开发者ID:ShifuML,项目名称:guagua,代码行数:17,代码来源:GuaguaSplitWriter.java

示例8: getSplitDetails

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "unused" })
private <T> T getSplitDetails(Path file, long offset) throws IOException {
    FileSystem fs = file.getFileSystem(getYarnConf());
    FSDataInputStream inFile = null;
    T split = null;
    try {
        inFile = fs.open(file);
        inFile.seek(offset);
        String className = Text.readString(inFile);
        Class<T> cls;
        try {
            cls = (Class<T>) getYarnConf().getClassByName(className);
        } catch (ClassNotFoundException ce) {
            IOException wrap = new IOException(String.format("Split class %s not found", className));
            wrap.initCause(ce);
            throw wrap;
        }
        SerializationFactory factory = new SerializationFactory(getYarnConf());
        Deserializer<T> deserializer = (Deserializer<T>) factory.getDeserializer(cls);
        deserializer.open(inFile);
        split = deserializer.deserialize(null);
    } finally {
        IOUtils.closeStream(inFile);
    }
    return split;
}
 
开发者ID:ShifuML,项目名称:guagua,代码行数:27,代码来源:GuaguaYarnTask.java

示例9: buildSetTraceMaskRequest

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
/**
 * Builds a SetTraceMask request to be sent to the server, consisting of
 * "stmk" followed by the 8-byte long representation of the trace mask.
 *
 * @param mask trace mask to set
 * @return built request
 * @throws IOException if there is an I/O error
 */
private String buildSetTraceMaskRequest(long mask) throws IOException {
    ByteArrayOutputStream baos = null;
    DataOutputStream dos = null;
    try {
        baos = new ByteArrayOutputStream();
        dos = new DataOutputStream(baos);
        dos.writeBytes("stmk");
        dos.writeLong(mask);
    } finally {
        IOUtils.closeStream(dos);
        IOUtils.closeStream(baos);
    }
    return new String(baos.toByteArray());
}
 
开发者ID:jdc91,项目名称:StreamProcessingInfrastructure,代码行数:23,代码来源:FourLetterWordsTest.java

示例10: saveInfoFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public void saveInfoFile(LocalStructure[][] inputls, Configuration conf) {

		String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);

		MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, MinutiaArray.class);

		Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
			public int compare(LocalStructure [] als1, LocalStructure [] als2) {
				return als1[0].getFpid().compareTo(als2[0].getFpid());
			}
		});

		Text fpid = new Text();

		for(LocalStructure [] ails : inputls) {
			fpid.set(ails[0].getFpid());

			Minutia [] ma = new Minutia[ails.length];

			try {
				for(int i = 0; i < ails.length; i++)
					ma[i] = ((LocalStructureCylinder) ails[i]).getMinutia();

				lsmapfile.append(fpid, new MinutiaArray(ma));
			} catch (IOException e) {
				System.err.println("LocalStructure.saveInfoFile: unable to save fingerprint "
						+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
				e.printStackTrace();
			}
		}

		IOUtils.closeStream(lsmapfile);

		return;
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:36,代码来源:PartialScoreLSSRImproved.java

示例11: saveLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static void saveLSMapFile(LocalStructure[][] inputls, Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
		
    	MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, inputls[0][0].newArrayWritable().getClass());
    	
    	Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
		   public int compare(LocalStructure [] als1, LocalStructure [] als2) {
		      return als1[0].getFpid().compareTo(als2[0].getFpid());
		   }
		});
    	
    	Text fpid = new Text();
    	ArrayWritable aw = null;

		for(LocalStructure [] ails : inputls) {
			fpid.set(ails[0].getFpid());
			
			ails = Util.removeNonValidLS(ails);

		    try {
		    	aw = ails[0].newArrayWritable(ails);
		    	lsmapfile.append(fpid, aw);
			} catch (IOException e) {
				System.err.println("LocalStructure.saveLSMapFile: unable to save fingerprint "
						+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
				e.printStackTrace();
			}
		}
		
		IOUtils.closeStream(lsmapfile);
		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:34,代码来源:LocalStructure.java

示例12: loadLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static <T extends LocalStructure> LocalStructure [][] loadLSMapFile(Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
		int length = Integer.parseInt(conf.get(Util.MAPFILELENGTHPROPERTY));
    	MapFile.Reader lsmapfile = Util.createMapFileReader(conf, name);
    	
    	LocalStructure [][] result = new LocalStructure[length][];
    	int i = 0;
    	
		WritableComparable<?> key = (WritableComparable<?>) ReflectionUtils.newInstance(lsmapfile.getKeyClass(), conf);

		ArrayWritable value = (ArrayWritable) ReflectionUtils.newInstance(lsmapfile.getValueClass(), conf);
		
		try {
			while(lsmapfile.next(key, value)) {
				Writable [] aw = value.get();
				result[i] = (LocalStructure []) Arrays.copyOf(aw, aw.length, LocalStructure[].class);
				i++;
			}
		} catch (Exception e) {
			System.err.println("LocalStructure.loadLSMapFile: unable to read fingerprint "
					+ key + " in MapFile " + name + ": " + e.getMessage());
			e.printStackTrace();
		}
		
		IOUtils.closeStream(lsmapfile);
		
		return result;		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:30,代码来源:LocalStructure.java

示例13: saveLSMapFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public static void saveLSMapFile(LocalStructure[][] inputls, Configuration conf) {

		String name = conf.get(Util.MAPFILENAMEPROPERTY, Util.MAPFILEDEFAULTNAME);
		
    	MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, inputls[0][0].newArrayWritable().getClass());
    	
    	Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
		   public int compare(LocalStructure [] als1, LocalStructure [] als2) {
		      return als1[0].getFpid().compareTo(als2[0].getFpid());
		   }
		});
    	
    	Text fpid = new Text();
    	ArrayWritable aw = null;

		for(LocalStructure [] ails : inputls) {
			fpid.set(ails[0].getFpid());

		    try {
		    	aw = ails[0].newArrayWritable(ails);
		    	lsmapfile.append(fpid, aw);
			} catch (IOException e) {
				System.err.println("LocalStructureCylinder.saveLSMapFile: unable to save fingerprint "
						+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
				e.printStackTrace();
			}
		}
		
		IOUtils.closeStream(lsmapfile);
		
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:32,代码来源:LocalStructureCylinder.java

示例14: saveInfoFile

import org.apache.zookeeper.common.IOUtils; //导入方法依赖的package包/类
public void saveInfoFile(LocalStructure[][] inputls, Configuration conf) {

		String name = conf.get(Util.INFOFILENAMEPROPERTY, Util.INFOFILEDEFAULTNAME);

		MapFile.Writer lsmapfile = Util.createMapFileWriter(conf, name, Text.class, MinutiaArray.class);

		Arrays.sort(inputls, new Comparator<LocalStructure[]>() {
			public int compare(LocalStructure [] als1, LocalStructure [] als2) {
				return als1[0].getFpid().compareTo(als2[0].getFpid());
			}
		});

		Text fpid = new Text();

		for(LocalStructure [] ails : inputls) {
			fpid.set(ails[0].getFpid());

			Minutia [] ma = new Minutia[ails.length];

			try {
				for(int i = 0; i < ails.length; i++)
					ma[i] = ((LocalStructureCylinder) ails[i]).getMinutia();

				lsmapfile.append(fpid, new MinutiaArray(ma));
			} catch (IOException e) {
				System.err.println("LocalStructure.saveLSMapFile: unable to save fingerprint "
						+ fpid.toString() + " in MapFile " + name + ": " + e.getMessage());
				e.printStackTrace();
			}
		}

		IOUtils.closeStream(lsmapfile);

		return;
	}
 
开发者ID:dperaltac,项目名称:bigdata-fingerprint,代码行数:36,代码来源:PartialScoreLSSR.java


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