Class LittleEndian
java.lang.Object
net.simplace.core.io.endian.LittleEndian
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertToLittleEndian(File aSourceFile, String aDivider, LinkedHashMap<String, FWSimVariable<?>> aHeaderInformation, File aTargetFile) Converts a CSV file (without header line) to a binary little-endian file.static Object[][]readFromLittleEndian(File aSourceFile, LinkedHashMap<String, FWSimVariable<?>> aHeaderInformation) Reads a binary little-endian file written byconvertToLittleEndian(File, String, LinkedHashMap, File)until the end of the file (BOOLEAN as 1 byte, as written).
-
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 fileaDivider- the column separatoraHeaderInformation- 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 byconvertToLittleEndian(File, String, LinkedHashMap, File)until the end of the file (BOOLEAN as 1 byte, as written).- Parameters:
aSourceFile- the binary fileaHeaderInformation- one variable per column (defines the data types)- Returns:
- one array of values per row, or
nullon number format errors (logged) - Throws:
IOException- if the file cannot be read
-