Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
HowToKB/src/kb/howtokb/tools/StructureConverter.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (22 sloc)
581 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kb.howtokb.tools; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class StructureConverter { | |
// Convert a string to a list of integer | |
public static List<Integer> stringToList(String s) { | |
List<Integer> listInt = new ArrayList<>(); | |
if (s == null || s.length() == 0) | |
return listInt; | |
if (s.contains(";")) { | |
String[] list = s.split(";"); | |
for (String l : list) { | |
if (!l.equals("-1")) | |
listInt.add(Integer.parseInt(l)); | |
} | |
} else { | |
if (!s.equals("-1")) | |
listInt.add(Integer.parseInt(s)); | |
} | |
return listInt; | |
} | |
} |