// Dividend Limit check or increase the Dividend
if (dival == 10) {
writer.println("Divident has reached it Limit !");
i++;
// update the file name
String upath = "channel_" + i;
System.out.println(path);
// find channel_1 and replace with the updated path
if (path.contains("channel_1")) {
path = "D:/File Compression/Data/low_freq/low_freq/house_1/"
+ upath + ".dat";
} else {
JOptionPane.showMessageDialog(null, "Invalid File Choosen");
System.exit(0);
}
dival = 10;
} else {
dival = dival + 10;
writer.println("Dividen:" + dival);
}
这些行采用递归方法。第一次给出正确的路径:
D:/File Compression/Data/low_freq/low_freq/house_1/channel_2.dat
但在第二次调用时,它会将正斜杠翻转为反斜杠:
D:\File Compression\Data\low_freq\low_freq\house_1\channel_1.dat
如果我不使用该条件,它可以正常工作。
if(path.contains("channel_"))