without Last Line - Java 2D Graphics

Java examples for 2D Graphics:Shape

Description

without Last Line

Demo Code


//package com.java2s;

public class Main {
    public static String withoutLastLine(String input) {
        int lastIndexOf = input.lastIndexOf('\n');
        if (lastIndexOf == -1 || lastIndexOf + 1 > input.length())
            return input;
        return input.substring(0, lastIndexOf + 1);
    }//from w  w  w  . jav a  2s.c  o m
}

Related Tutorials