commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Kendall <matt_kend...@iname.com>
Subject [betwixt] Array of java.io.File objects.
Date Wed, 16 Nov 2005 23:14:15 GMT
I've been tearing my hair out on this all afternoon. I've tried
configuring Betwixt in way too many different ways to list them all
here, so instead I'll just ask: what's the best way to handle the File
object, specifically an array of file objects? I would like the
following code to print out "2 == 2".

public class FileTest {
	private File[] files;
	
	public File[] getFiles() {
		return files;
	}
	
	public void setFiles(File[] files) {
		this.files = files;
	}

	public static void main(String[] args) {
		FileTest test = new FileTest();

		test.setFiles(new File[] { new File("a.txt"), new File("b.txt") });

		try {
			BeanWriter writer = new BeanWriter(new FileWriter("ftout.xml"));
			writer.enablePrettyPrint();
			writer.write(test);
			writer.flush();
			writer.close();
			
			BeanReader reader = new BeanReader();
			reader.registerBeanClass(FileTest.class);
			test = (FileTest) reader.parse("ftout.xml");
			
			System.out.println("2 == " + test.getFiles().length);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

I apologize if this question is too vague, but I've created so many
mappers, converters, chains, etc. that enumerating all of them is much
more complicated than simply understanding what I want from the
following code.

Oh, and the one solution I cannot employ is to rewrite the bean that I
need to convert to XML. I didn't write it so I cannot change it.

Thanks!
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message