-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringModifications.java
More file actions
31 lines (26 loc) · 1.22 KB
/
StringModifications.java
File metadata and controls
31 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package javaCycle;
import java.io.*;
import java.util.*;
// javac -d . StringModifications.java
// -d . will create stringModifications/StringModifications.class, which then can be included with import stringModifications.StringModifications; and called with StringModifications.Split_string(par);
public class StringModifications {
public static ArrayList<String> Array2ArrayList(String[] input){
// Convert Array into an Arraylist
ArrayList<String> output = new ArrayList<String>();
for (int ii=0; ii<input.length; ii++){
output.add(input[ii]); }
return output;
}
public static List<ArrayList<String>> SplitStringTrim(List<String> content, String delimiter ){
// Split each entry in a list of strings by a delimiter
List<ArrayList<String>> content_split = new ArrayList<ArrayList<String>>();
content.forEach((content_entry) ->
{
String[] splitStr = content_entry.trim().split(delimiter);
ArrayList<String> splitStr_a = Array2ArrayList(splitStr); // Convert Array into an Arraylist
content_split.add(splitStr_a);
}
);
return content_split;
}
}