本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}