Search in sources :

Example 1 with Key

use of au.gov.amsa.ihs.reader.Key in project risky by amsa-code.

the class SabineMain method main.

public static void main(String[] args) throws FileNotFoundException {
    File file = new File("/media/an/ship-data/ihs/608750-2015-04-01.zip");
    List<Key> keys = Arrays.asList(Key.LRIMOShipNo, Key.ShipName, Key.ShipbuilderCompanyCode, Key.CountryOfBuildCode, Key.MainEngineBuilderCode, Key.MainEngineDesignerCode, Key.MainEngineModel, Key.MainEngineType, Key.PropulsionTypeCode, Key.PropulsionType, Key.DeathDate, Key.DeliveryDate, Key.DateOfBuild, Key.Deadweight, Key.GrossTonnage, Key.LengthOverallLOA, Key.LiquidCapacity, Key.TEU, Key.PassengerCapacity, Key.StatCode5, Key.ShipStatus, Key.ShipStatusCode, Key.ShipStatusEffectiveDate, Key.FlagCode, Key.ClassificationSocietyCode, Key.DocumentofComplianceDOCCompanyCode);
    try (PrintStream out = new PrintStream("target/ships.txt")) {
        out.println(keys.stream().map(key -> key.name()).collect(Collectors.joining("\t")));
        IhsReader.fromZip(file).map(map -> {
            return keys.stream().map(key -> map.get(key.name())).map(x -> x == null ? "" : x).collect(Collectors.joining("\t"));
        }).doOnNext(out::println).subscribe();
    }
}
Also used : PrintStream(java.io.PrintStream) Key(au.gov.amsa.ihs.reader.Key) Arrays(java.util.Arrays) List(java.util.List) IhsReader(au.gov.amsa.ihs.reader.IhsReader) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) PrintStream(java.io.PrintStream) File(java.io.File) Key(au.gov.amsa.ihs.reader.Key)

Aggregations

IhsReader (au.gov.amsa.ihs.reader.IhsReader)1 Key (au.gov.amsa.ihs.reader.Key)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintStream (java.io.PrintStream)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1