Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jul 14, 2009 at 11:20 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Raj,

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

      BTW: Solved it on my own.

      Thanks

      regards Mairo

  • avatar image
    Former Member
    Jul 14, 2009 at 11:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 14, 2009 at 11:36 AM

    solved on my own.

    Add comment
    10|10000 characters needed characters exceeded