Java‎ > ‎

String Manipulation

Remove NULL bytes in a string: JAVA

String outputString = inputString().trim().replaceAll("\0", "");


Split strings by whitespaces

myString.split("\\s+");


Convert List of Strings to an Array of Strings

import java.util.ArrayList;
import java.util.List;


public class test2 {

/**
* @param args
*/
public static void main(String[] args) {
List<String> myList = new ArrayList<String>();
myList.add("ONE");
myList.add("TWO");

String[] stringArray = myList.toArray(new String[0]);
for(int i = 0; i < stringArray.length; i++)
System.out.println(stringArray[i]);
}

}


Comments