public class parseFiles
{
public static void main(String... aArgs) throws FileNotFoundException
{
File startingDirectory= new File("CGT");
List<File> files = FileListing2.getFileListing(startingDirectory);
for(File file : files )
{
System.out.println(file);
}
}
<other methods to supply the file listings, etc.>
}
これが私が今いるところです。これはうまく機能し、フルパスを持つファイルのリストが問題なくコンソールに出力されます。ここで、その出力にリストされている各ファイルを取得し、それらを1行ずつ読み取ります。
BufferedReader br = new BufferedReader(new FileReader(file));
String inputLine;
String desc = "";
String docNo = "";
//
while ((inputLine = br.readLine()) != null)
{
int testVal=0;
String delim = ",";
int stringMax = inputLine.length();
if(inputLine.startsWith("Description"))
{desc = inputLine.substring(13,inputLine.length());}
else
if(inputLine.startsWith("Reference Number"))
{docNo = inputLine.substring(20,inputLine.length());}
String outputString = desc+delim+docNo;
//
<write series of output strings to flat file>
//
}
while ((inputLine = br.readLine()) != null)
次のエラーでキックバックを続けます:
FileListing2.java:22: error: unreported exception FileNotFoundException; must be
caught or declared to be thrown
List<File> files = FileListing2.getFileListing(startingDirectory);
^
FileListing2.java:30: error: unreported exception FileNotFoundException; must be
caught or declared to be thrown
BufferedReader br = new BufferedReader(new FileReader(file));
^
FileListing2.java:43: error: unreported exception IOException; must be caught or
declared to be thrown
while ((inputLine = br.readLine()) != null)
^
3 errors