Here you can find the source of removeTrailingEmptyLines(String[] lines)
public static String[] removeTrailingEmptyLines(String[] lines)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Arrays; public class Main { public static String[] removeTrailingEmptyLines(String[] lines) { ArrayList<String> linesList = new ArrayList<String>(Arrays.asList(lines)); boolean bEndEmptyLine = linesList.get(linesList.size() - 1).equals(""); while (bEndEmptyLine) { linesList.remove(linesList.size() - 1); bEndEmptyLine = linesList.get(linesList.size() - 1).equals(""); }/*from w ww .j av a 2 s .co m*/ String[] newLines = new String[linesList.size()]; linesList.toArray(newLines); return newLines; } }