4

I have a text file that I need to send as part of a SOAP request over web service.

Could someone please share the code of getting this text file into a Data Handler (in java)? I know it probably involves streams not sure of the exact code.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
AbuMariam
  • 3,282
  • 13
  • 49
  • 82
  • Very similar to this http://stackoverflow.com/questions/2830561/how-to-convert-an-inputstream-to-a-datahandler, check that – Koitoer Sep 16 '14 at 17:43
  • I actually already saw this, but they were talking about Data sources and custom classes and wrapping, my guess is something like my requirement could be done in 3-4 lines of code. – AbuMariam Sep 16 '14 at 18:16

1 Answers1

6

I think I figured it out..

 DataSource fds = new FileDataSource("C:/DBMigrations/Sample_Upload_Tasks.txt");
 DataHandler handler = new DataHandler(fds);

Just create a file data source and give it the file and create a handler based on that data source.

AbuMariam
  • 3,282
  • 13
  • 49
  • 82