cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping: simulate in ECLIPSE: main method: write file

Former Member
0 Kudos

Hi evrybody,

how to I have to modify my main method, taht the outputstream is written to my disc?

// the following is in the main[] method
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		try {
// main[] calls execute

			new myJAVAMapping().execute((InputStream) is, os);
		} catch (Exception e) {
			e.printStackTrace();
		}
// here I want to write the ByteArrayOutputStream to disc.
???

Thx regards Mario

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

solved on my own.

0 Kudos

Hi Mulelr,

in order to test your java mapping as a standalone application, you need usee input and output streams for reading and writing files from and to the local disk.

the code may look like the below one:

public static void main(String[] args) {
		try {
			File file = new File("d:/in.xml");
			System.out.println("" + file.getAbsolutePath());
			InputStream in = new FileInputStream(file);
			OutputStream out = new FileOutputStream(new File("d:/output.xml"));
			MappingEX myMapping = new MappingEX();
			myMapping.execute(in, out);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

in the given code "MappingEX" is the Class name of your mapping program. As well for input and out put stream you can specify the location where u want read from and write to.

Regards

Venkat

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Mulelr,

If you want test you java mapping locally for that you have to write main method in JAVA Mapping,

add below code

public static void main(String[] args) {

try {

Classname fec = new ClassName();

FileInputStream in =

new FileInputStream("C:");

OutputStream out = new ByteArrayOutputStream();

fec.execute(in, out);

} catch (Exception e) {

System.out.println(e);

}

}

Classname means give your javamapping class name here.

Then if you want to see the out put.

using System.out.println method printh the out pust stream.

Regards,

Raj

Former Member
0 Kudos

Hi Raj,

as I write: I want to write the outputStrem to disc.

BTW: Solved it on my own.

Thanks

regards Mairo