TXT文本中如据形如: 
-2,2
-1,3
 0,1
 1,9
 2,8读入二维数组效果为: 
temp[0][]={-2,-1, 0, 1, 2}; 
temp[1][]={ 2, 3,1,9,8}; 新手 
请大家指点 

解决方案 »

  1.   

    temp[5][2] = {{-2,2}, {-1, 3}, {0, 1}, {1, 9}, {2, 8}}
      

  2.   

    public static void main(String[] args) {
         ArrayList<String> temp1=new ArrayList<String>();
    ArrayList<String> temp2=new ArrayList<String>();
         try{    
             FileInputStream fstream = new FileInputStream("textfile.txt");
             DataInputStream in = new DataInputStream(fstream);
             BufferedReader br = new BufferedReader(new InputStreamReader(in));
             
             String strLine;
             while ((strLine = br.readLine()) != null)   {
              if (strLine.split(",").length==2){
              temp1.add(strLine.split(",")[0]);
              temp2.add(strLine.split(",")[1]);
              }
             }
             in.close();
          }catch (Exception e){
               System.err.println("Error: " + e.getMessage());
          }
          String temp[][] = new String[2][];
          temp[0] = (String[]) temp1.toArray();
          temp[1] = (String[]) temp2.toArray();        
        }
      

  3.   

    2楼看起来蛮工整的。
    流用的有点乱,既然用Reader了,就不要用DataInputStream了。
    in.close();->br.close();