我正在读取属性文件
actiontimer = properties.getProperty("action1");
我得到一个字符串,并希望将其转换为计时器以便稍后在我的程序中使用它。
private Timer actiontimer
类型转换不起作用,我得到:
Cannot cast from String to Timer
我该如何进行此类型转换?
更新:
属性文件中的格式:
action1:12314
最佳答案
将字符串转换为整数。
现在使用[Timer's Schedule]传递一个 int 作为参数。
String s = "12314";
Integer delay = Integer.parseInt(s);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
}
};
timer.schedule(task, delay);
关于java - 如何将 java.lang.String 转换为 java.util.Timer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13527668/