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
.retrieve
;
9 import gov
.nasa
.worldwind
.exception
.WWRuntimeException
;
10 import gov
.nasa
.worldwind
.util
.Logging
;
12 import java
.util
.logging
.Level
;
16 * @version $Id: RetrieveToFilePostProcessor.java 2471 2007-07-31 21:50:57Z tgaskins $
18 public final class RetrieveToFilePostProcessor
implements RetrievalPostProcessor
20 java
.io
.File destination
;
24 * @throws IllegalArgumentException if <code>destination</code> is null
26 public RetrieveToFilePostProcessor(java
.io
.File destination
)
28 if (destination
== null)
30 String message
= Logging
.getMessage("nullValue.DestNull");
31 Logging
.logger().severe(message
);
32 throw new IllegalArgumentException(message
);
35 this.destination
= destination
;
41 * @throws IllegalArgumentException if <code>retriever</code> is null
43 public java
.nio
.ByteBuffer
run(Retriever retriever
)
45 if (retriever
== null)
47 String message
= Logging
.getMessage("nullValue.RetrieverIsNull");
48 Logging
.logger().severe(message
);
49 throw new IllegalArgumentException(message
);
54 java
.nio
.ByteBuffer buffer
= retriever
.getBuffer();
57 Logging
.logger().log(Level
.SEVERE
, "RetrieveToFilePostProcessor.NullBufferPostprocessing",
62 java
.io
.FileOutputStream fos
= null;
65 fos
= new java
.io
.FileOutputStream(this.destination
);
66 fos
.getChannel().write(buffer
);
69 catch (java
.io
.IOException e
)
79 catch (java
.io
.IOException e
)
81 String message
= Logging
.getMessage("RetrieveToFilePostProcessor.ErrorPostprocessing", retriever
.getName());
82 Logging
.logger().severe(message
);
83 throw new WWRuntimeException(message
, e
);