[jdom-interest] Problem with a "deprecation API" error.

Danny J. danny.james at home.com
Fri Jun 15 17:03:28 PDT 2001


Hello - I am trying to write a simple Java application that reads the first
two layer of files/folders into a XML formate (with JDOM). For an example if
I had C:\someText.txt and C:\dev\somePic.jpg....I want my app to make a xml
file like this

<?xml version="1.0"?>
    <FileSystem>
          </C:\someText.txt>

            <C:\dev>
                </C:\dev\somePic.jpg>
            </C:\dev>

    </FileSystem>

-------------------------------------------------------

I'm in the early process of trying to make my app do this using JDOM Beta 6,
but for some reason I am getting an error saying I am using a depcrecated
API on the lines with doc.addContent. Here is the code, any help would be
appreciated.

-------------------------------------------------------

import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class Brewer {
Document doc;
    public Brewer() {

        try {
           Document doc = new Document(new Element("FileSystem"));



        File root1 = new File("E:" + File.separator + "dev");
        File[] child = root1.listFiles();


        for(int k = 0; k<child.length; k++) {
        File f = child[k];

        if(f.isDirectory()) {
            System.out.println("" + f);
                File[] childX = f.listFiles();

                for(int j = 0; j< childX.length; j++) {
                  doc.addContent(new Element(""+childX[j]));
                }
        }

        else if (f.isFile()) {
 doc.addContent(new Element(""+f));

        }

        }
        }
        catch (Exception e) {
        }

                    try {
             String oDoc = "Files.xml";
            XMLOutputter fmt = new XMLOutputter();
            fmt.output(doc,  new FileOutputStream(oDoc));

                }
                catch (Exception ex) {
                }

    }

    public static void main (String args[]) {
    Brewer b = new Brewer();
    }
}






More information about the jdom-interest mailing list