66import static gov .usgs .earthquake .nshmp .data .XySequence .emptyCopyOf ;
77import static java .nio .ByteOrder .LITTLE_ENDIAN ;
88import static java .nio .charset .StandardCharsets .UTF_8 ;
9+ import static java .nio .file .StandardOpenOption .APPEND ;
10+ import static java .nio .file .StandardOpenOption .CREATE ;
11+ import static java .nio .file .StandardOpenOption .TRUNCATE_EXISTING ;
12+ import static java .nio .file .StandardOpenOption .WRITE ;
913
1014import java .io .IOException ;
1115import java .nio .ByteBuffer ;
1216import java .nio .channels .FileChannel ;
1317import java .nio .file .Files ;
1418import java .nio .file .OpenOption ;
1519import java .nio .file .Path ;
16- import java .nio .file .StandardOpenOption ;
1720import java .sql .Timestamp ;
1821import java .util .EnumMap ;
1922import java .util .List ;
@@ -161,7 +164,6 @@ private void init(Sites sites) throws IOException {
161164 }
162165 }
163166
164-
165167 for (Imt imt : config .hazard .imts ) {
166168
167169 Path imtDir = dir .resolve (imt .name ());
@@ -324,7 +326,7 @@ private void writeHazard(Hazard hazard) throws IOException {
324326 String totalLine = toLine (locData , totalCurve .yValues (), valueFormatter );
325327
326328 Path totalFile = imtDir .resolve (CURVE_FILE_ASCII );
327- writeLine (totalFile , totalLine , StandardOpenOption . APPEND );
329+ writeLine (totalFile , totalLine , APPEND );
328330
329331 Metadata meta = null ;
330332 int binIndex = -1 ;
@@ -350,7 +352,7 @@ private void writeHazard(Hazard hazard) throws IOException {
350352 writeBinary (typeBinFile , meta , typeCurve , binIndex );
351353 }
352354 }
353- writeLine (typeFile , typeLine , StandardOpenOption . APPEND );
355+ writeLine (typeFile , typeLine , APPEND );
354356 }
355357 }
356358
@@ -369,7 +371,7 @@ private void writeHazard(Hazard hazard) throws IOException {
369371 writeBinary (gmmBinFile , meta , gmmCurve , binIndex );
370372 }
371373 }
372- writeLine (gmmFile , gmmLine , StandardOpenOption . APPEND );
374+ writeLine (gmmFile , gmmLine , APPEND );
373375 }
374376 }
375377 }
@@ -666,7 +668,7 @@ private void writeBinary(
666668 Metadata meta ,
667669 XySequence curve ,
668670 int curveIndex ) throws IOException {
669- FileChannel channel = FileChannel .open (path , StandardOpenOption . WRITE );
671+ FileChannel channel = FileChannel .open (path , WRITE );
670672 int position = HEADER_OFFSET + curveIndex * meta .curveByteSize ;
671673 toBuffer (curve , meta .buffer );
672674 channel .write (meta .buffer , position );
@@ -682,7 +684,7 @@ private static void toBuffer(XySequence curve, ByteBuffer buffer) {
682684 }
683685
684686 private void initBinary (Path path , Metadata meta ) throws IOException {
685- FileChannel channel = FileChannel .open (path , StandardOpenOption . WRITE );
687+ FileChannel channel = FileChannel .open (path , CREATE , TRUNCATE_EXISTING , WRITE );
686688 ByteBuffer header = createHeader (meta );
687689 header .flip ();
688690 channel .write (header );
0 commit comments