logo
  • Home
  • Contact
💵
Should I be buying I-Bonds in 2023?
💰
Need a step-by-step guide to opening your Roth IRA?
Buy me a coffee Buy me a coffee
aws c++ career cli css docker finance git java js misc python sql

How to Split String on Forward Slash in Java


How can we split a string on the forward slash in Java?

Suppose we’re working with this string:

String str = "a/b/c";

We need an array with the elements: ["a", "b", "c"].

To do this, we can simply use split() with the forward slash as the delimiter. No need to escape the forward slash.

String[] arr = str.split("/");

Check out additional ways to split strings over some delimiter in Java.


Related in Java

How to Extract String Between Parentheses in Java
How to Run Tasks in Parallel with ExecutorService and CompletableFuture in Java
How to Check if a Date is Between Two Dates in Java (Date, LocalDate, Instant)
How to Split by Vertical Pipe Symbol "|" in Java
How to Get All Appenders in Logback Context in Java
How to Convert from Date to LocalDate in Java
How to Retry a Task in Java using Guava's Retryer
How to Convert Between Millis, Minutes, Hours, Days (and more) in Java
How to Ignore Generated Files in IntelliJ's Find in Files (Search Bar)
How to Check If a List Contains Object by Field in Java
How to Get Part of an Array or List in Java
What is the double colon (::) in Java? It's just a method reference!
How to Check If a File Exists in Java
How to Convert an InputStream to a File in Java
How to Convert a List<Long> to List<Integer> in Java (or vice versa!)
How to Get Current Timestamp (Epoch) in Milliseconds in Java
© , LogFetch   âˆ™   Advertise Here   âˆ™   Privacy Policy