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


Java ObjectInputStream.available方法代码示例

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


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

示例1: loadStats

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Loads the statistics from a file
 */
protected static void loadStats(){
	JFileChooser chooser = new JFileChooser();
	chooser.setFileFilter(new FileNameExtensionFilter("Keys per second statistics file", "kpsstats"));
	chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	if(chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION){
		return;
	}
	try{
		ObjectInputStream in = new ObjectInputStream(new FileInputStream(chooser.getSelectedFile()));
		TotPanel.hits = in.readInt();
		avg = in.readDouble();
		max = in.readInt();
		n = in.readLong();
		prev = in.readInt();
		tmp.set(in.readInt());
		while(in.available() > 0){
			Key key = keys.get(in.readInt());
			Key obj = ((Key)in.readObject());
			if(key != null){
				key.count = obj.count;
			}
		}
		in.close();
		frame.repaint();
		graphFrame.repaint();
		JOptionPane.showMessageDialog(null, "Statistics succesfully loaded", "Keys per second", JOptionPane.INFORMATION_MESSAGE);
	}catch(IOException | ClassNotFoundException e){
		JOptionPane.showMessageDialog(null, "Failed to load the statistics!", "Keys per second", JOptionPane.ERROR_MESSAGE);
	}
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:34,代码来源:Main.java

示例2: loadLegacyFormat

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Loads a legacy configuration file
 * @param saveloc The save location
 * @return Whether or not the config was loaded successfully
 */
@SuppressWarnings("unchecked")
private final boolean loadLegacyFormat(File saveloc){
	try {
		ObjectInputStream objin = new ObjectInputStream(new FileInputStream(saveloc));
		keyinfo = (List<KeyInformation>) objin.readObject();
		showMax = objin.readBoolean();
		showCur = objin.readBoolean();
		showAvg = objin.readBoolean();
		showGraph = objin.readBoolean();
		graphAvg = objin.readBoolean();
		backlog = objin.readInt();
		updateRate = objin.readInt();
		double version = 3.0D;
		if(objin.available() > 0){
			customColors = objin.readBoolean();
			background = (Color)objin.readObject();
			foreground = (Color)objin.readObject();
			if(objin.available() > 0){
				trackAll = objin.readBoolean();
				showKeys = objin.readBoolean();
				if(objin.available() > 0){
					version = objin.readDouble();
				}
			}
		}
		if(version >= 3.9){
			precision = objin.readInt();
		}
		if(version >= 3.10){
			opacitybg = objin.readFloat();
			opacityfg = objin.readFloat();
		}
		if(version >= 4.0D){
			size = objin.readDouble();
		}
		if(version >= 4.2D){
			overlay = objin.readBoolean();
		}
		objin.close();
		for(KeyInformation info : keyinfo){
			if(version < 3.7D){
				info.visible = true;
			}
			if(info.index > KeyInformation.autoIndex){
				KeyInformation.autoIndex = info.index + 1;
			}
		}
		return true;
	} catch (Exception e1) {
		e1.printStackTrace();
		return false;
	}
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:59,代码来源:Configuration.java


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