Java - Write code to truncate specified last N char

Requirements

Write code to truncate specified last N char

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String aString = "book2s.com";
        int N = 2;
        System.out.println(truncateLastNChar(aString, N));
    }// w ww. j a  v a  2s. c  om

    /**
     * truncate specified last N char
     * @param    aString the source string
     * @param    N   the number of char to truncate
     * @return   the truncated string
     */
    public static String truncateLastNChar(String aString, int N) {
        int length = aString.length();

        int indexOfTrancate = length - N;

        return aString.substring(0, indexOfTrancate);
    }
}