You can do it in two steps with StringUtils only,

List<String> s = new ArrayList<>();
s.add("one");
s.add("two");
s.add("three");

String step1 = StringUtils.join(s, "\", \"");// Join with ", "
String step2 = StringUtils.wrap(step1, "\"");// Wrap step1 with "

System.out.println(step2);

Output,

"one", "two", "three"

BUT

I need to pass them in a mongo DB query when using $in operator

For mongodb query you don't need to build it this way, specifically in case of $in you can query documents in following way,

BasicDBObject yourInQuery = new BasicDBObject();
yourInQuery.put("in_column", new BasicDBObject("$in", yourList));
DBCursor cursor = collection.find(yourInQuery);

Please read more about this in following link,

  • Find or Query Data with Java Driver
Answer from Akash Thakare on Stack Overflow
Discussions

Best way to convert list to comma separated string in java - Stack Overflow
I have Set result & would like to convert it to comma separated string. My approach would be as shown below, but looking for other opinion as well. List slist = new More on stackoverflow.com
🌐 stackoverflow.com
java - How to convert a List<String> into a comma separated string without iterating List explicitly - Stack Overflow
I am having ArrayList of String, which I need to convert to comma separated list, without space. The ArrayList toString() method adds square brackets, comma and space. More on stackoverflow.com
🌐 stackoverflow.com
How to convert comma separated and double quoted words string to list/array of strings in Java - Stack Overflow
I have the below input string: "["role_A","role_B","role_C"]" I want to convert it to a list/array of strings containing all values(role_A, role_B, role_C).... More on stackoverflow.com
🌐 stackoverflow.com
[regex] How to parse comma separated values with commas inside quotes included.

How about this?

public static void main(String[] args) {
  try {
    Files.readAllLines(Paths.get("/tmp/file.csv")).forEach(line -> {
      for (final String token : line.split("(\",)?\"")) {
        if (!token.isEmpty()) {
          System.out.println(token);
        }
      }
    });
  } catch (IOException ex) {
    ex.printStackTrace();
  }
}
More on reddit.com
🌐 r/javahelp
4
3
February 23, 2018
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-a-list-of-string-to-a-comma-separated-string-in-java
Convert a List of String to a comma separated String in Java - GeeksforGeeks
January 23, 2026 - List of String: [Geeks, ForGeeks, GeeksForGeeks] Comma separated String: Geeks,ForGeeks,GeeksForGeeks ... String.join() combines all list elements into one string.
🌐
Medium
medium.com › @AlexanderObregon › turning-a-java-list-into-a-comma-separated-string-efc1b6c44d1b
Turning a Java List into a Comma-Separated String | Medium
June 20, 2025 - Using StringBuilder to turn a list into a comma-separated string is one of the cleaner ways to handle the job when you want control over how the string is built. It gives you a way to piece things together.
🌐
Bitcompiler
tutorials.bitcompiler.com › 2024 › 03 › how-to-convert-list-of-strings-to-comma.html
How to convert a List of Strings to a Comma Separated String with Single Quotes In Java
This Java code uses Java Streams to map each element of the list to a string with single quotes around it using the map operation. Then, it collects these strings into a single comma-separated string using the Collectors.joining method.
🌐
Medium
medium.com › @as.vignesh › append-quotes-to-strings-in-an-array-and-make-it-comma-separated-string-in-java-5dbb9edccaa8
Append quotes to strings in an array and make it comma ...
Open in app · Sign up · Sign in · Write · PAGE NOT FOUND · Out of nothing, something · You can find (just about) anything on Medium — apparently even a page that doesn’t exist. Maybe these stories will take you somewhere new · A fascinating variety of Irish facts, brought to you ...
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › article › java-program-to-convert-a-list-of-string-to-comma-separated-string
Java program to convert a list of string to comma separated string
August 26, 2025 - In Java 8 and later, we can use the method Collectors.joining() from the Streams API to convert a list of strings to a comma-separated string.
🌐
Baeldung
baeldung.com › home › java › java string › convert a list to a comma-separated string
Convert a List to a Comma-Separated String | Baeldung
July 2, 2025 - Let’s take the following list ... utilities for String processing and provides the conversion method join(): String commaSeparatedString = String.join(",", arraysAsList); assertThat(commaSeparatedString).isEqualTo("ONE,TW...
🌐
Medium
medium.com › @alxkm › converting-a-list-of-strings-to-a-comma-separated-string-in-java-multiple-approaches-ebb86745c889
Java Interview: Converting a List of Strings to a Comma-Separated String in Java: Multiple Approaches | by Alex Klimenko | Medium
August 9, 2025 - StringBuilder sb = new StringBuilder(); for (int i = 0; i < names.size(); i++) { sb.append(names.get(i)); if (i < names.size() - 1) { sb.append(","); } } String result = sb.toString(); System.out.println(result); // Output: Alice,Bob,Charlie · Works in all Java versions.
🌐
DZone
dzone.com › coding › java › convert a list to a comma-separated string in java 8
Convert a List to a Comma-Separated String in Java 8
June 29, 2016 - package net.reversecoding.examples; import static java.util.stream.Collectors.joining; import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.List; import org.junit.Test; public class CsvUtil { private static final String SEPARATOR = ","; public static String toCsv(List < String > listToConvert) { return String.join(SEPARATOR, listToConvert); } @Test public void toCsv_csvFromListOfString() { List < String > cities = Arrays.asList( "Milan", "London", "New York", "San Francisco"); String expected = "Milan,London,New York,San Francisco"; assertEquals(expected, toCs
🌐
Attacomsian
attacomsian.com › blog › java-convert-list-to-comma-separated-string
Convert a list to a comma-separated string in Java
October 29, 2022 - You can use core Java functions, Steams API, and Apache Commons Lang to convert a list into a string. The most common way to convert a list of strings into a comma-separated string is by using the static join() method from the String class:
🌐
Sabe
sabe.io › blog › java-convert-list-comma-separated-string
How to Convert a List to Comma-Separated String in Java | Sabe
May 25, 2022 - The most straight-forward way to convert a string list to a comma-separated string is to use the join() method that exists on the String class. Simply call the join() method on the list and pass in the separator you want to use.
🌐
Java67
java67.com › 2018 › 10 › how-to-convert-list-or-set-of-string-to-comma-separated-string-in-java-csv.html
How to Convert a List of String to Comma Separated String (CSV) in Java 8? Example | Java67
JDK 8 has provided a utility class called StringJoiner as well as added a join() method into String class to convert a List, Set, Collection, or even array of String objects to a comma-separated String in Java.
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-arraylist-to-comma-separated-string-in-java
Convert ArrayList to Comma Separated String in Java - GeeksforGeeks
July 23, 2025 - We can convert ArrayList to a comma-separated String using StringJoiner which is a class in java.util package which is used to construct a sequence of characters(strings) separated by a delimiter and optionally starting with a supplied prefix ...
🌐
Coderanch
coderanch.com › t › 433460 › java › Convert-List-comma-delimited-string
Convert List to comma delimited string (Beginning Java forum at Coderanch)
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos] Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2 ... And Mike's code also included another good advice: use StringBuilder instead of String for all the adding.