MCPcopy
hub / github.com/arduino/Arduino / split

Method split

arduino-core/src/processing/app/legacy/PApplet.java:105–134  ·  view source on GitHub ↗

Split a string into pieces along a specific character. Most commonly used to break up a String along a space or a tab character. This operates differently than the others, where the single delimeter is the only breaking point, and consecutive delimeters will produce an empty string (""). This wa

(String what, char delim)

Source from the content-addressed store, hash-verified

103 * column alignments (of say an excel file) where there are empty columns.
104 */
105 static public String[] split(String what, char delim) {
106 // do this so that the exception occurs inside the user's
107 // program, rather than appearing to be a bug inside split()
108 if (what == null)
109 return null;
110
111 char chars[] = what.toCharArray();
112 int splitCount = 0; // 1;
113 for (int i = 0; i < chars.length; i++) {
114 if (chars[i] == delim)
115 splitCount++;
116 }
117 if (splitCount == 0) {
118 String splits[] = new String[1];
119 splits[0] = new String(what);
120 return splits;
121 }
122 String splits[] = new String[splitCount + 1];
123 int splitIndex = 0;
124 int startIndex = 0;
125 for (int i = 0; i < chars.length; i++) {
126 if (chars[i] == delim) {
127 splits[splitIndex++] = new String(chars, startIndex, i - startIndex);
128 startIndex = i + 1;
129 }
130 }
131 splits[splitIndex] = new String(chars, startIndex, chars.length
132 - startIndex);
133 return splits;
134 }
135
136 static public String[] subset(String list[], int start, int count) {
137 String output[] = new String[count];

Callers 15

checkPathMethod · 0.95
savePreferencesDataMethod · 0.95
AbstractMonitorMethod · 0.95
uploadUsingProgrammerMethod · 0.80
burnBootloaderMethod · 0.80
forceRefreshMethod · 0.80
getFileCachedMethod · 0.80
parseMethod · 0.80

Calls

no outgoing calls

Tested by 1

toLocaleMethod · 0.64