Java - Write code to cut string from left

Requirements

Write code to cut string from left

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        int len = 4;
        System.out.println(left(str, len));
    }//from  w ww  . ja v a 2  s  .co m

    private static final String EMPTY = "";

    public static String left(String str, int len) {
        if (str == null) {
            return null;
        }
        if (len < 0) {
            return EMPTY;
        }
        if (str.length() <= len) {
            return str;
        }
        return str.substring(0, len);
    }
}