Read file

xiaoxiao2021-03-06  41

Import java.util.Arraylist; import java.io. *;

public class ReadCSVFile {public static ArrayList readFile (String filename) {// BUG 000-000761 FileReader fileReader = null; BufferedReader reader = null; ArrayList fileList = new ArrayList ();

try {File file = new File (filename); // BUG 000-000761 // BufferedReader reader = new BufferedReader (new FileReader (file)); fileReader = new FileReader (file); reader = new BufferedReader (fileReader);

String stratay [] = null; string strstr = ""; int strnum = 0;

String csvarray [] = null; string csvstr = ""; int CSVNUM = 0;

ArrayList Arr = NULL; int Num; int CNT;

String strcsv = NULL;

While ((strcsv = reader.readline ())! = null) {arr = new arraylist (); if (strcsv.charat (0) == # ') {Continue;}

IF (strcsv.trim (). Length () == 0) {Continue;}

Strarray = split (strCSV, ",");

For (Strnum = 0, CNT = strnum

// bug 000-000761 try {fileReader.close (); read (Exception E) {filelist = null;}

Return Filelist;}

Private static string str2to1 (string str) {string retstr = ""; for (int i = 0, cnt = str.length (); i

Private static int number {int Num = 0; for (INT i = 0, cnt = str.length (); i

转载请注明原文地址:https://www.9cbs.com/read-54439.html

New Post(0)