Java String Left left(String s, int nCaratteri)

Here you can find the source of left(String s, int nCaratteri)

Description

left

License

Apache License

Declaration

public static String left(String s, int nCaratteri) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*  w ww . j  av  a 2 s.  co m*/
     */
    public static String left(String s, int nCaratteri) {

        if (s == null)
            return null;

        if (nCaratteri < 1)
            return "";

        if (nCaratteri >= s.length())
            return s;

        return s.substring(0, nCaratteri);
    }
}

Related

  1. left(final String text, final String sep)
  2. left(Object src, int length, String defaultValue)
  3. left(String baseString, int pos)
  4. left(String s, int l)
  5. left(String s, int len)
  6. left(String s, int size)
  7. left(String s, int width)
  8. left(String source, int length)
  9. left(String source, String searchFor)