Class LittleEndian

java.lang.Object
net.simplace.core.io.endian.LittleEndian

public final class LittleEndian extends Object
Converts CSV data to a binary little-endian file and back. DOUBLE values are stored as 4 byte floats, INT as 4 byte integers and BOOLEAN as 1 byte; other types are skipped (a warning is logged).
Author:
Andreas Enders
  • Constructor Details

    • LittleEndian

      public LittleEndian()
  • Method Details

    • convertToLittleEndian

      public static void convertToLittleEndian(File aSourceFile, String aDivider, LinkedHashMap<String, FWSimVariable<?>> aHeaderInformation, File aTargetFile) throws IOException
      Converts a CSV file (without header line) to a binary little-endian file. Number format errors are logged.
      Parameters:
      aSourceFile - the CSV file
      aDivider - the column separator
      aHeaderInformation - one variable per column (defines the data types)
      aTargetFile - the binary file to write
      Throws:
      IOException - if a file cannot be read or written
    • readFromLittleEndian

      public static Object[][] readFromLittleEndian(File aSourceFile, LinkedHashMap<String, FWSimVariable<?>> aHeaderInformation) throws IOException
      Reads a binary little-endian file written by convertToLittleEndian(File, String, LinkedHashMap, File) until the end of the file (BOOLEAN as 1 byte, as written).
      Parameters:
      aSourceFile - the binary file
      aHeaderInformation - one variable per column (defines the data types)
      Returns:
      one array of values per row, or null on number format errors (logged)
      Throws:
      IOException - if the file cannot be read