Here you can find the source of substringAndchopLastNewline(String text, int start_pos, int end_pos)
public static String substringAndchopLastNewline(String text, int start_pos, int end_pos)
//package com.java2s; /* StringUtilRegular.java - realm of regular expressions. * * Copyright (c) 2005-2011 Andrew Krizhanovsky <andrew.krizhanovsky at gmail.com> * Distributed under GNU Public License. *///w w w .jav a2 s .c o m public class Main { private final static String NULL_STRING = new String(); /** Gets text substring from 'start_pos' position till 'end_pos' position * and chop last symbol if it is newline \n symbol. */ public static String substringAndchopLastNewline(String text, int start_pos, int end_pos) { if (start_pos < 0 || start_pos >= end_pos || end_pos > text.length() - 1) { return NULL_STRING; } if (end_pos > 0 && '\n' == text.charAt(end_pos - 1)) { end_pos--; } return text.substring(start_pos, end_pos); } }