Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to split a String

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.63k
    Comment on it

    Below I have written a code to split a string.

    Suppose we have a string name imagePath and we are going to split by "/" by using split method in java.


     String delimiter = "/";
      String[] img;
    if (imagePath.contains("/")) {
     img = imagePath.split(delimiter);
      for(int i =0; i < img.length ; i++)
        System.out.println(img[i]);
    } else {
        throw new IllegalArgumentException(string + " doesnt contain /");
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: