java - 我无法读取总行数,有些行被混淆了
问题描述
我需要调试下面的代码来跟踪从 while 循环开始的一些意外结果。我在while循环的行中放置了断点,但调试器没有到达它我希望调试器在该行之前运行所有代码然后停在要逐步调试的行我该怎么做公共类MainActivity扩展AppCompatActivity {
Button readExcelButton;
static String TAG = "ExelLog";
ArrayList<PhoneData> phoneData = new ArrayList<PhoneData>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void readFile(View view) {
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {
Log.e(TAG, "Storage not available or read only");
return;
}
try {
// 创建输入流
File file = new File(this.getExternalFilesDir(null), "3.xls");
// FileInputStream myInput = new FileInputStream(file);
InputStream inStream;
Workbook wb = null;
inStream = new FileInputStream(file);
// 使用文件系统创建工作簿
wb = new HSSFWorkbook(inStream);
// 从工作簿获取第一张工作表 Sheet sheet1 = wb.getSheetAt(0);
int totalNumberOfRows = sheet1.getLastRowNum();
Log.d(TAG, "RowsNo: " + totalNumberOfRows);
int i = 6;
while (i <= totalNumberOfRows) {
if (sheet1.getRow(i).getCell(16).getCellTypeEnum() == CellType.NUMERIC) {
double duration = sheet1.getRow(i).getCell(16).getNumericCellValue();
if (duration > .91 && duration < 1) {
//sheet1.getRow(i).getCell(8).setCellType(CellType.NUMERIC);
double status = sheet1.getRow(i).getCell(8).getNumericCellValue();
if (status == 60 || status == 72 || status == 73 || status == 101) {
System.out.println("if succeed");
Double telephone = sheet1.getRow(i).getCell(2).getNumericCellValue();
int tel = telephone.intValue();
System.out.println("telephone is" + tel);
}
//Toast.makeText(this, "Telephone Number: " + Double.toString(telephone), Toast.LENGTH_SHORT).show();
// String exchange = sheet1.getRow(i).getCell(1).getStringCellValue();
// String complainTime =sheet1.getRow(i).getCell(5).getStringCellValue();
// phoneData.add(new PhoneData(Double.toString(telephone), exchange,Double.toString(status),complainTime));
// System.out.println("exchange is"+exchange + duration+status+complainTime );
}
System.out.println("Test Data From Excel" + duration);
System.out.println("Row Number" + i);
} else {
System.out.println("Not Numeric");
}
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
return;
}
private static boolean isExternalStorageReadOnly() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {
return true;
}
return false;
}
private static boolean isExternalStorageAvailable() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
return true;
}
return false;
}
}
解决方案
推荐阅读
- html - 背景图像被“最小高度”截断 - 如何解决?
- github - “现在是一个特殊的存储库:它的 README.md 将出现在您的个人资料中!” 但它不起作用
- 3d - 如何从仅给出几个点的值中插入不规则点云的颜色?
- flutter - Flutter 搭建网页
- scaladoc - Scaladoc 参考文档 - 它存在吗?
- symfony - 来自数据库的 Symfony Mailer 动态传输
- azure - Azure Databricks 在集群已运行时等待集群启动
- postgresql - Global variables implementation using plperl/plpython in postgres is throwing out of memory
- javascript - How can I toggle between tabs after I make an api call to populate them
- c - Access Ada (in a .so) from Java JNI