0

I want to read data using SimpleBinaryBufferedReaderFactory, can anyone has any code snippet or link where i can understand the working.

I am skeptical on how to tell reader to when is the end of chunk. Like in case of text file there was endLine character in each line which was reading by LineMapper but my data does not contains endLine. I want to end the chunk when some byte is traversed.

How to tell reader to when to chunk it and get bytes for each chunk.

  • Regardless of Spring Batch, what is your input and what are you trying to achieve? – Mahmoud Ben Hassine Sep 22 '20 at 07:04
  • @Mahmoud Ben Hassine, my input is video file, i want to read that video file in bytes. – Vishal Singh Sep 23 '20 at 16:40
  • What is an item in your case? If you have a single video file, using a chunk oriented step does not make sense to me (what would be an item in this case?). If you have multiple video files, then an item could be one video file, in this case, you can use an `ItemReader` for example. – Mahmoud Ben Hassine Sep 25 '20 at 06:45
  • @Mahmoud Ben Hassine, Yes, I have multiple video file BUT i am taking one video file at a time as one JOB and here an **item will some specific amount of bytes[].** Thats why i am doing chunk oriented step. `FlatFileItemReader reader = new FlatFileItemReader<>(); reader.setResource(new UrlResource(url));` So, i am able to access the video file in bytes but Reader is expecting LineMapper() and this part I am skeptical. How to tell line mapper when to chunk it. (As line mapper take **String line** and here i don't have String. – Vishal Singh Sep 26 '20 at 18:40
  • @MahmoudBenHassine If i do this: `reader.setLineMapper(new LineMapper() { @Override public byte[] mapLine(String line, int lineNumber) throws Exception { return line.getBytes(); }});` It is working fine with txt file but when my input is video file then, Its not working. The file created at destination is double the size of input file. – Vishal Singh Sep 26 '20 at 18:48
  • I don't see the reason to read a single video file in a chunk-oriented fashion. `The file created at destination is double the size of input file`: that's probably an issue on the writer side (it should be writing the same (amount of) bytes returned by the reader). – Mahmoud Ben Hassine Sep 28 '20 at 07:24
  • @MahmoudBenHassine I am doing chunk-oriented because my video file could be very big and I want to read it bytes by bytes. What if I have a 4k video file and I don't have capacity to read whole file at once? Sorry if I sound fool but I am trying to transfer big video file in chucks, same as springBatch do it for records by records, I want to do it same for video file but instead of record my one item will be some byte[] from video file. Is it possible to implement? – Vishal Singh Sep 29 '20 at 18:40
  • @vishalsingh are you able to solve this ? I am having same problem, please share if you are able to transfer large binary file with chunk – Tilak Nov 17 '21 at 23:19

0 Answers0