lrgs.archive.MinuteFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opendcs Show documentation
Show all versions of opendcs Show documentation
A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.
The newest version!
/*
* $Id$
*
* This is open-source software written by ILEX Engineering, Inc., under
* contract to the federal government. You are free to copy and use this
* source code for your own purposes, except that no part of this source
* code may be claimed to be proprietary.
*
* Except for specific contractual terms between ILEX and the federal
* government, this source code is provided completely without warranty.
* For more information contact: [email protected]
*
* $Log$
* Revision 1.1 2008/04/04 18:21:11 cvs
* Added legacy code to repository
*
* Revision 1.4 2005/10/20 18:01:05 mmaloney
* event nums
*
* Revision 1.3 2005/09/19 21:31:50 mmaloney
* dev
*
* Revision 1.2 2005/06/24 15:57:28 mjmaloney
* Java-Only-Archive implementation.
*
* Revision 1.1 2005/06/06 21:15:26 mjmaloney
* Added new Java-Only Archiving Package
*
*/
package lrgs.archive;
import java.io.IOException;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import ilex.util.Logger;
/**
This class contains static methods for reading & writing a day file's
minute-index. The file is a binary array of 1440 MsgIndexMinute objects.
*/
public class MinuteFile
{
/**
* Loads the array of MsgIndexMinute entries from the named file.
* @param fn the file name.
* @param mns the array of MsgIndexMinute structures to fill.
*/
public static void load( String fn, MsgIndexMinute[] mns )
throws IOException
{
DataInputStream dis = null;
try
{
dis = new DataInputStream(
new BufferedInputStream(
new FileInputStream(fn)));
for(int i=0; i 60000L) // after 1st minute of day?
Logger.instance().warning(
MsgArchive.module + ":" + MsgArchive.EVT_BAD_MINUTE_FILE
+ "- Error reading '" + fn + "': " + ex);
if (dis != null)
{
try { dis.close(); }
catch(IOException ignore) {}
}
throw ex;
}
}
/**
* Saves the array of MsgIndexMinute entries to the named file.
* @param fn the file name.
* @param mns the array of MsgIndexMinute structures to save.
*/
public static void save( String fn, MsgIndexMinute[] mns )
throws IOException
{
DataOutputStream dos = null;
try
{
dos = new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(fn)));
for(int i=0; i