FileInputFormat看这一段源码
这是FileInputFormat中的一个方法,看一下它的功能,多看源码,理解hadoop,同时提高自己的java编程能力:
private static String[] getPathStrings(String commaSeparatedPaths) {
int length = commaSeparatedPaths.length();
int curlyOpen = 0;
int pathStart = 0;
boolean globPattern = false;
List<String> pathStrings = new ArrayList<String>();
for (int i=0; i<length; i++) {
char ch = commaSeparatedPaths.charAt(i);
switch(ch) {
case \'{\’ : {
curlyOpen++;
if (!globPattern) {
globPattern = true;
}
break;
}
case \’}\’ : {
curlyOpen–;
if (curlyOpen == 0 && globPattern) {
globPattern = false;
}
break;
}
case \’,\’ : {
if (!globPattern) {
pathStrings.add(commaSeparatedPaths.substring(pathStart, i));
pathStart = i + 1 ;
}
break;
}
default:
continue; // nothing special to do for this character
}
}
pathStrings.add(commaSeparatedPaths.substring(pathStart, length));
return pathStrings.toArray(new String[0]); //这句我都看不懂额。The simple form with no arguments creates a new array of Object
. The more complex form allows the caller to //provide an array or to choose the runtime type of the output array
}