I am trying to take specific values from a file to write to the database through Java. I have used the substring()
function to store values. In one column, I have some empty fields and some with data. When it encounters an empty field, it gives me an error. How to fix this?
String st = strline.substring(453,457);
I am getting this error in output due to the above code:
Error: begin 453, end 457, length 452
像厄立特里亚一样,你应该在调用substring方法之前检查字符串的长度。
String st = strline.length() > 452 ? strline.substring(453,457) : "";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.