java找不到符号IOException,Java Netbeans错误找不到符号,符号:类出,位置:类System,< identifier>预期类型的​​非法开始...

I'm getting an error in Netbeans in my driver class on this line:

System.out.print("Time waited is: " + (serializedTime - System.currentTimeMillis())/1000 + " secs.");

The error is: "Cannot find symbol, symbol: class out, location: class System, expected, illegal start of type.

import domain.PersistentObject;

import domain.PopulationRecord;

import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

import java.util.logging.Level;

import java.util.logging.Logger;

import utilities.MiniProj2Utilities;

public class MiniProj2Driver {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// Make sure that you develop your main() method with reduced code as shown below.

// Not the use of private static methods in the driver called from main() method.

// Read the CSV file records into a list of PopulationRecord objects...

List popList = MiniProj2Utilities.getDataRecords();

// Display the list contents and size...

MiniProj2Utilities.displayRecordsFromList(popList);

// Create and populate the PersistentObject...

PersistentObject po = MiniProj2Utilities.getPersistentObject(popList);

try {

ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("./data/population-record.ser"));

oos.writeObject(po);

} catch (IOException ex) {

}

long serializedTime = System.currentTimeMillis();

System.out.println(po);

try {

Thread.sleep(5000);

} catch (InterruptedException ex) {

System.out.println("Sleep Error");

}

try {

ObjectInputStream oos = new ObjectInputStream(new FileInputStream("./data/population-record.ser"));

PersistentObject po1 = (PersistentObject)oos.readObject();

} catch (IOException ex)

{

} catch (ClassNotFoundException ex) {

}

}

System.out.print("Time waited is: " + (serializedTime - System.currentTimeMillis())/1000 + " secs.");

// Read the CSV file records into a list of PopulationRecord objects...

private static List getDataRecords() {

BufferedReader br = null;

String line = null;

List list = new ArrayList();

try {

br = new BufferedReader(new FileReader("data/NST_EST2011_ALLDATA.csv"));

br.readLine(); // Remove header line from file...

while ((line = br.readLine()) != null) {

String[] tokens = line.split(",");

//System.out.println(line);

PopulationRecord pr = new PopulationRecord(

tokens[0], tokens[1], tokens[2], tokens[3], tokens[4],

Integer.parseInt(tokens[5]), Integer.parseInt(tokens[6]),

Long.parseLong(tokens[7]), Long.parseLong(tokens[8]),

Long.parseLong(tokens[9]), Long.parseLong(tokens[10]),

Long.parseLong(tokens[11]), Long.parseLong(tokens[12]),

Long.parseLong(tokens[13]), Long.parseLong(tokens[14]),

Long.parseLong(tokens[15]), Long.parseLong(tokens[16]),

Long.parseLong(tokens[17]), Long.parseLong(tokens[18]),

Long.parseLong(tokens[19]), Long.parseLong(tokens[20]),

Long.parseLong(tokens[21]), Long.parseLong(tokens[22]),

Long.parseLong(tokens[23]), Long.parseLong(tokens[24]),

Long.parseLong(tokens[25]), Long.parseLong(tokens[26]),

Long.parseLong(tokens[27]), Long.parseLong(tokens[28]),

Long.parseLong(tokens[29]));

list.add(pr);

}

} catch (FileNotFoundException ex) {

Logger.getLogger(MiniProj2Driver.class.getName()).log(Level.SEVERE, null, ex);

} catch (IOException ex) {

Logger.getLogger(MiniProj2Driver.class.getName()).log(Level.SEVERE, null, ex);

}

return list;

}

// Display the list contents and size...

private static void displayRecordsFromList(List list) {

for (PopulationRecord record : list) {

System.out.println(record);

}

System.out.println("Population records processed: " + list.size() + list.get(9));

}

private static PersistentObject getPersistentObject(List list) {

PersistentObject po = new PersistentObject();

po.setSerializedTime(new Date());

po.setPopulationList(list);

return po;

}

}

解决方案

One issue is, your System.out statement is outside method.

}

System.out.print("Time waited is: " + (serializedTime - System.currentTimeMillis())/1000 + " secs.");

move it to inside the braces

System.out.print("Time waited is: " + (serializedTime - System.currentTimeMillis())/1000 + " secs.");

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值