セパレータ「!」付きの csv ファイルを読み込みたい。しかし、Android アプリケーションで次のコードを実行すると、アプリケーション全体がハングします。問題を解決するために私に助けを提供してください。
入力ファイルをメモ帳で開くと、次のようになります。
/////////////////////////////////////////////////////////
Line Number"!Shift!"QC Operator"!"Line Operator"!"Printing Operator"!"Product
Group"!"Product Series"!Product!" Type of Defect"!"PCBType"!CORRECTIVE ACTION (CA)
1!DAY!Deepak!Chetan!Arun!TIMER!MM30XX!55Q!NO Solder!POWER!REWORK
2!NIGHT!Kajal!Kajal!Ashish!TEMP!MM10XX!55Q!Less solder!LOGIC!Replacement
3!!Kavita!Mahesh G!B.C!COUNTER!TC!EM306A!Dry solder!DISPLAY!NA
4!!Madhuri!Mahesh.P!Pabitra!PLC!PID !EM368 !IC PIN SOLDER SHORT!CARD!
5!!Namita!Namita!Sachin!METER!XT!EM368-C!Tombs toning!!
!!Sneha!Naveen!Sayali!DPM!800!MF16 !One side open !!
///////////////////////////////////////////////////////
ファイルを読み取るためのコード:
public void ReadConfigFile() throws IOException
{
File myFile = new File(Environment.getExternalStorageDirectory() + File.separator + "QCVerification"+ File.separator+"List of Entries.csv");
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
String aDataRow = "";
ArrayList<String> FileWholeData = new ArrayList<String>();
FileWholeData.removeAll(null);
while ((aDataRow = myReader.readLine()) != null)
{
FileWholeData.add(aDataRow);
}
MyQcDataStructure = new QCDataStructure();
for(Integer __index = 0;__index <FileWholeData.size();__index++)
{
String TempString = "";
TempString = FileWholeData.get(__index);
StringTokenizer tokenizer = new StringTokenizer(TempString,"!");
int columnIndex = 0;
while (tokenizer.hasMoreTokens())
{
switch (columnIndex)
{
case 0:
MyQcDataStructure.QCLineNo.add(tokenizer.nextToken());
break;
case 1:
MyQcDataStructure.QCShift.add(tokenizer.nextToken());
break;
case 2:
MyQcDataStructure.QCQCOPer.add(tokenizer.nextToken());
break;
case 3:
MyQcDataStructure.QCLineOper.add(tokenizer.nextToken());
break;
case 4:
MyQcDataStructure.QCPrintingOper.add(tokenizer.nextToken());
break;
case 5:
MyQcDataStructure.QCProductGorup.add(tokenizer.nextToken());
break;
case 6:
MyQcDataStructure.QCProductSeries.add(tokenizer.nextToken());
break;
case 7:
MyQcDataStructure.QCProduct.add(tokenizer.nextToken());
break;
case 8:
MyQcDataStructure.QCPDefect.add(tokenizer.nextToken());
break;
case 9:
MyQcDataStructure.QCPCBType.add(tokenizer.nextToken());
break;
case 10:
MyQcDataStructure.QCCA.add(tokenizer.nextToken());
break;
}
columnIndex++;
}
break;
}
String aBuffer;
aBuffer = "";
for(int __secondIndex = 0;__secondIndex < MyQcDataStructure.QCLineNo.size();__secondIndex++)
{
aBuffer = aBuffer + MyQcDataStructure.QCLineNo.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCShift.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCQCOPer.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCLineOper.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCPrintingOper.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCProductGorup.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCProductSeries.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCProduct.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCPDefect.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCPCBType.get(__secondIndex);
aBuffer = aBuffer + "$";
aBuffer = aBuffer + MyQcDataStructure.QCCA.get(__secondIndex);
aBuffer = aBuffer + "$";
}
txtData.setText(aBuffer);
myReader.close();
Toast.makeText(getBaseContext(),
"Done reading santosh SD 'mysdfile.txt'",
Toast.LENGTH_SHORT).show();
}
しかし、アプリケーションで次のコードを実行すると、アプリケーションがハングします。
while (tokenizer.hasMoreTokens())
{
switch (columnIndex)
{
この問題を解決するための助けをいただければ幸いです。