Java:非法启动表达式错误

时间:2015-01-19 14:52:47

标签: java

import java.io.*;

公共课ReadCSV {

public static void main(String [] args){

ReadCSV obj = new ReadCSV();
obj.run();
//obj.setUpMyCSV();
//obj.printMyArray();

}

public void run(){

String csvFile = "C:/Users/Aditi Site/Desktop/infert.csv";
File file = new File(csvFile);
BufferedReader br = null;
String line = "";
String csvSplitBy = ",";

try {
    int sum=0;
    br = new BufferedReader(new FileReader(csvFile));
    while ((line = br.readLine()) != null) {

            // use comma as separator
        String[] infert = line.split(csvSplitBy);

        System.out.println("infert [education= " + infert[1] 
                            + " , age=" + infert[2] + " , parity=" + infert[3] +" , induced=" + infert[4] +" , case=" + infert[5] +" , spontaneous=" + infert[6] +" , stratum=" + infert[7] +" , pooled.stratum=" + infert[8] +"]");

        }



} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} finally {
    if (br != null) {
        try {
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

//我在以下方法中遇到错误:

public void setUpMyCSV()
{
Double myArray=new double[200][200];
Scanner scanIn=null;
int r=0;
int rc=0;
int cc=0;
int c=0;
String Inputline=" ";
double xnum=0;
String xfilelocation;
xfilelocation= "C:/Users/Aditi Site/Desktop/infert.csv";
try
    {
    scanIn=new Scanner(new BufferedReader(newFileReader (xfilelocation)));
    while(scanIn.hasNextLine())
    {   InputLine=scanIn.nextLine();
        String[] InArray=InputLine.split(",");
        for(int x=0;x<InArray.length;x++)
        {
        myArray[rc][x]=Double.parseDouble(InArray[x]);
        }
        rc++;

    }
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
} 

//我在以下方法中遇到错误:

public void printMyArray()
{
Double myArray=new double[200][200];
for(int rc=0;r<130;r++)
    {
        for(int cc=0;c<130;c++)
        {
            System.out.println(myArray[rc][cc]+ "  ");
        }
        System.out.println();
    }
//return;
}

} }

我收到以下错误: 非法开始表达 public void printMyArrat public void setUpMyCSV

1 个答案:

答案 0 :(得分:0)

你还没有关闭run方法。通过添加&#34;}&#34;关闭它(紧密支撑)就在public void setUpMyCSV()

之前