retrievetofilepostprocessor.java
来自「world wind java sdk 源码」· Java 代码 · 共 94 行
JAVA
94 行
/*Copyright (C) 2001, 2006 United States Governmentas represented by the Administrator of theNational Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.retrieve;import gov.nasa.worldwind.exception.WWRuntimeException;import gov.nasa.worldwind.util.Logging;import java.util.logging.Level;import java.nio.channels.ClosedByInterruptException;/** * @author Tom Gaskins * @version $Id: RetrieveToFilePostProcessor.java 5859 2008-08-06 20:20:49Z tgaskins $ */public final class RetrieveToFilePostProcessor implements RetrievalPostProcessor{ java.io.File destination; /** * @param destination * @throws IllegalArgumentException if <code>destination</code> is null */ public RetrieveToFilePostProcessor(java.io.File destination) { if (destination == null) { String message = Logging.getMessage("nullValue.DestNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.destination = destination; } /** * @param retriever * @return * @throws IllegalArgumentException if <code>retriever</code> is null */ public java.nio.ByteBuffer run(Retriever retriever) { if (retriever == null) { String message = Logging.getMessage("nullValue.RetrieverIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } try { java.nio.ByteBuffer buffer = retriever.getBuffer(); if (buffer == null) { Logging.logger().log(Level.SEVERE, "RetrieveToFilePostProcessor.NullBufferPostprocessing", retriever.getName()); return null; } java.io.FileOutputStream fos = null; try { fos = new java.io.FileOutputStream(this.destination); fos.getChannel().write(buffer); return null; } catch (java.io.IOException e) { throw e; } finally { if (fos != null) fos.close(); } } catch (ClosedByInterruptException e) { Logging.logger().log(java.util.logging.Level.FINE, Logging.getMessage("generic.OperationCancelled", "retrieval to file"), e); return null; } catch (java.io.IOException e) { String message = Logging.getMessage("RetrieveToFilePostProcessor.ErrorPostprocessing", retriever.getName()); Logging.logger().severe(message); throw new WWRuntimeException(message, e); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?