2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
;
11 * @version $Id: RetrieveToFilePostProcessor.java 510 2007-01-17 04:57:40Z ericdalgliesh $
13 public final class RetrieveToFilePostProcessor
implements RetrievalPostProcessor
15 java
.io
.File destination
;
19 * @throws IllegalArgumentException if <code>destination</code> is null
21 public RetrieveToFilePostProcessor(java
.io
.File destination
)
23 if (destination
== null)
25 String message
= WorldWind
.retrieveErrMsg("nullValue.DestNull");
26 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
27 throw new IllegalArgumentException(message
);
30 this.destination
= destination
;
36 * @throws IllegalArgumentException if <code>retriever</code> is null
38 public java
.nio
.ByteBuffer
run(Retriever retriever
)
40 if (retriever
== null)
42 String message
= WorldWind
.retrieveErrMsg("nullValue.RetrieverIsNull");
43 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
44 throw new IllegalArgumentException(message
);
49 java
.nio
.ByteBuffer buffer
= retriever
.getBuffer();
52 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, WorldWind
.retrieveErrMsg(
53 "RetrieveToFilePostProcessor.NullBufferPostprocessing") + retriever
.getName());
57 java
.io
.FileOutputStream fos
= null;
60 fos
= new java
.io
.FileOutputStream(this.destination
);
61 fos
.getChannel().write(buffer
);
64 catch (java
.io
.IOException e
)
74 catch (java
.io
.IOException e
)
76 String message
= WorldWind
.retrieveErrMsg("RetrieveToFilePostProcessor.ErrorPostprocessing") + retriever
78 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
79 throw new WWRuntimeException(message
, e
);