java中能将从文件中读取的字符作为方法的参数使用吗?如果能,怎么实现呢?

解决方案 »

  1.   

    也试过直接做的,但好像不行。如:
           FileReader readFile = new FileReader("graph.txt");
           BufferedReader rf = new BufferedReader(readFile);

           row = rf.readLine();
           while(rf.read() != -1) {
                 int first = row.charAt(0) - 48;
                 int second = row.charAt(1) - 48;
         addEdge( first,second); //表示两数间有一条边
                 //adjMat[first][second] = 1;//表示两数间有一条边
            }
     这样出现了以后的编译错误:
    non-static variable adjMat cannot be referenced from a static context
              addEdge(first,second) ;     
    // non-static variable adjMat cannot be referenced from a static context
              adjMat[first][second] = 1