The Java implementation of the design is composed of the source files listed below.
Since we are focusing on the logical design, have already covered the basic DOM operations with Java, and discussed earlier some advanced DOM programming considerations, I won't have very many comments here or in the C++ section. The Java implementation is portable, so we can't make assumptions about the directory path separator character. To get it we use the System class getProperty method on the file.separator property, as follows : sDirectorySeparator = System.getProperty("file.separator"); To create an output directory in the CSVSourceConverter's processFile method, we use the mkdir method of the File class. File FilePath = new File(sOutputDirectory); FilePath.mkdir(); To read an input directory in the XMLToCSV main program, we again use the File class, passing the input directory name in the constructor. We then call the list method, returning an array of strings with the file names. These are the local names within the directory, so we must prefix them with the directory path before opening them. InputDirectory = new File(sInputDirectoryName); FilesList = InputDirectory.list(); if (FilesList != null) { // Get first file from input directory // DO for all files in input directory for (i=0; i < FilesList.length; i++) { // Build input file name sInputFileName = sInputDirectoryName + FilesList[i]; // DOM Document <- Load input file, validating it if // requested docInput = Builder.parse(new File(sInputFileName)); |