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


Java IOUtils类代码示例

本文整理汇总了Java中org.mapsforge.core.util.IOUtils的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: serializeMap

import org.mapsforge.core.util.IOUtils; //导入依赖的package包/类
/**
 * Serializes the cache map.
 * 
 * @param directory
 *            the directory of the serialized map file.
 * @param map
 *            the map to be serialized.
 * @return true if the map was serialized successfully, false otherwise.
 */
private static boolean serializeMap(File directory, Map<MapGeneratorJob, File> map) {
	File serializedMapFile = new File(directory, SERIALIZATION_FILE_NAME);
	if (serializedMapFile.exists() && !serializedMapFile.delete()) {
		return false;
	}

	FileOutputStream fileOutputStream = null;
	ObjectOutputStream objectOutputStream = null;
	try {
		fileOutputStream = new FileOutputStream(serializedMapFile);
		objectOutputStream = new ObjectOutputStream(fileOutputStream);
		objectOutputStream.writeObject(map);
		return true;
	} catch (IOException e) {
		LOGGER.log(Level.SEVERE, null, e);
		return false;
	} finally {
		IOUtils.closeQuietly(objectOutputStream);
		IOUtils.closeQuietly(fileOutputStream);
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:31,代码来源:FileSystemTileCache.java

示例2: getRenderTheme

import org.mapsforge.core.util.IOUtils; //导入依赖的package包/类
public static RenderTheme getRenderTheme(GraphicAdapter graphicAdapter, XmlRenderTheme xmlRenderTheme)
		throws SAXException, ParserConfigurationException, IOException {
	RenderThemeHandler renderThemeHandler = new RenderThemeHandler(graphicAdapter,
			xmlRenderTheme.getRelativePathPrefix());
	XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
	xmlReader.setContentHandler(renderThemeHandler);
	InputStream inputStream = null;
	try {
		inputStream = xmlRenderTheme.getRenderThemeAsStream();
		xmlReader.parse(new InputSource(inputStream));
		return renderThemeHandler.renderTheme;
	} finally {
		IOUtils.closeQuietly(inputStream);
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:16,代码来源:RenderThemeHandler.java

示例3: deserializeObject

import org.mapsforge.core.util.IOUtils; //导入依赖的package包/类
private static Object deserializeObject(File file) throws IOException, ClassNotFoundException {
	FileInputStream fileInputStream = null;
	ObjectInputStream objectInputStream = null;
	try {
		fileInputStream = new FileInputStream(file);
		objectInputStream = new ObjectInputStream(fileInputStream);
		return objectInputStream.readObject();
	} finally {
		IOUtils.closeQuietly(objectInputStream);
		IOUtils.closeQuietly(fileInputStream);
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:13,代码来源:TestUtils.java

示例4: serializeObject

import org.mapsforge.core.util.IOUtils; //导入依赖的package包/类
private static void serializeObject(Object objectToSerialize, File file) throws IOException {
	FileOutputStream fileOutputStream = null;
	ObjectOutputStream objectOutputStream = null;
	try {
		fileOutputStream = new FileOutputStream(file);
		objectOutputStream = new ObjectOutputStream(fileOutputStream);
		objectOutputStream.writeObject(objectToSerialize);
	} finally {
		IOUtils.closeQuietly(objectOutputStream);
		IOUtils.closeQuietly(fileOutputStream);
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:13,代码来源:TestUtils.java


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