UserLuke
UserLuke

Reputation: 215

How upload text file in Vaadin to textField?

I know how upload and save file. But how to upload the file without saving on disk and display text-data in TextArea or TextField.

Upvotes: 0

Views: 684

Answers (1)

André Schild
André Schild

Reputation: 4754

When using the vaadin upload you should be able to use a ByteArrayOutputStream instead of a FileOutputStream.

So just use the sample from the book of vaadin but use a ByteArrayOuputStream instead.

When the uploadSucceeded method is called, you take the ByteArrayOutputStream, convert it into a string (Beware of the correct encoding) and set it as the value of your TextArea/Field.

Upvotes: 2

Related Questions