Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { private static final String JOSHUA_SEPARATOR = "|||"; public static List<Double> getTotalWeightsFromNBestListString(String nBestListAsString) { List<Double> result = new ArrayList<Double>(); String[] lines = nBestListAsString.split("\n"); for (String line : lines) { result.add(getTotalWeightFromNBestLine(line)); } return result; } public static Double getTotalWeightFromNBestLine(String nBestLine) { int firstIndexWeightSubstring = nBestLine.lastIndexOf(JOSHUA_SEPARATOR) + JOSHUA_SEPARATOR.length(); String weightSubstring = nBestLine.substring(firstIndexWeightSubstring); return Double.parseDouble(weightSubstring); } }