Thank you Lorenz,
I tested the 2nd option and it works. Thanks a lot
Best regards
Chavdar


________________________________
От: Lorenz Buehmann <[email protected]>
Изпратено: петък, 27 декември 2019 г., 10:24 ч.
До: [email protected]
Тема: Re: Output model in test field


On 26.12.19 16:25, Dr. Chavdar Ivanov wrote:
> Hello all,
>
> Merry Christmas to all of you.
>
> I have a question related to model write (or similar functions/methods)
> I would like to show part or the whole model in a text area in GUI. I was 
> looking at some possibilities to reuse model.write or other related methods, 
> but could not manage so far. Perhaps output stream can be used somehow

Why not? Either use e.g. ByteArrayOutputStream or Writer.

model.write allows for a Writer object as argument, Java has
StringWriter as one of many implementations of Writer interface

(untested):

Writer sw = new StringWriter();
model.write(sw, "Turtle");
String s = sw.toString(); // done

or

ByteArrayOutputStream os = new ByteArrayOutputStream();
model.write(os, "Turtle");
String s = os.toString("UTF-8"); // done

// you can also close() both resources (or better use AutoClosable)
although not really necessary

>
> I need to have the model as text as String so that I can set it to the text 
> field
>
> Any idea?
>
>
> Best regards
> Chavdar
>


Reply via email to