[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Split and pass empty strings

Posted on 2006-03-27
Medium Priority
Last Modified: 2010-04-01
I have the following code that bombs if rawClassification = "::"; How do I get it to pass two empty strings in this case?

String[] myClassificationPieces = rawClassification.split("::");
      request.setAttribute("classification_category" , myClassificationPieces[0]) ;
      request.setAttribute("classification_subcategory" , myClassificationPieces[1]) ;
Question by:894359
1 Comment
LVL 29

Accepted Solution

bloodredsun earned 2000 total points
ID: 16306132
You need to check the length of the array before you refer to them by direct index like myArray[5] else you will get an ArrayOutOfBoundsException as you are probably seeing

String[] myClassificationPieces = rawClassification.split("::");
if (myClassificationPieces.length >= 2 ){
     request.setAttribute("classification_category" , myClassificationPieces[0]) ;
     request.setAttribute("classification_subcategory" , myClassificationPieces[1]) ;

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2016 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question