From 427bca13cc9357dc859542a17eef9b546b30163f Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Tue, 16 Sep 2014 10:35:54 +0200 Subject: [PATCH] add check to prevent LuiShenReader to throw IndexOutOfBoundsException when reading file ending with empty lines --- .../java/jsprit/instance/reader/LuiShenReader.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java b/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java index 80d9d8c5..fd1d9553 100644 --- a/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java +++ b/jsprit-instances/src/main/java/jsprit/instance/reader/LuiShenReader.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (C) 2013 Stefan Schroeder - * + * Copyright (C) 2014 Stefan Schroeder + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . ******************************************************************************/ @@ -45,7 +45,6 @@ public class LuiShenReader { public LuiShenReader(VehicleRoutingProblem.Builder vrpBuilder) { super(); this.vrpBuilder = vrpBuilder; -// this.vrpBuilder.setFleetComposition(FleetComposition.HETEROGENEOUS); } /** @@ -76,6 +75,7 @@ public class LuiShenReader { String[] tokens = line.split(" +"); counter++; if(counter > 9){ + if(tokens.length < 7) continue; Coordinate coord = makeCoord(tokens[1],tokens[2]); String customerId = tokens[0]; int demand = Integer.parseInt(tokens[3]);