Last active
May 6, 2016 07:59
-
-
Save sharif2008/59f5854e6c962cd23a161b84199e1c9d to your computer and use it in GitHub Desktop.
Get a substring with N character in JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String getNcharacters(int n, String s){ | |
if(s==null) | |
return ""; | |
return s.substring(0, Math.min(s.length(), n)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment