zoukankan      html  css  js  c++  java
  • 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
    }

  • 相关阅读:
    从程序员到技术总监,分享10年开发经验
    CF739E Gosha is hunting
    hdu 4891 模拟
    hdu4888 最大流(构造矩阵)
    hdu4888 最大流(构造矩阵)
    hdu4885 有 限制的最短路
    hdu4885 有 限制的最短路
    hdu4884 模拟
    hdu4884 模拟
    POJ1789简单小生成树
  • 原文地址:https://www.cnblogs.com/Robin008/p/9100672.html
Copyright © 2011-2022 走看看