1

I have a special file where the lines are terminated by '\001'.

I want to read this file line by line. I have been using Files.lines(path). but this fails now, since the lines are not terminated by new line character.

what is the best way to do?

brain storm
  • 30,124
  • 69
  • 225
  • 393
  • Read whole file as a string, and using [`StringTokenizer`](https://www.javatpoint.com/string-tokenizer-in-java) with `\001` as delimiter to split line by line. Or you can using `String.split` function to split it into an array then read one by one – TuyenNTA Jul 14 '17 at 23:24

1 Answers1

4

If it has '\001' instead of newline chars, you can read the whole file and split the string at the '\001' using split.

Alternatively, you can use delimiters

npit
  • 2,219
  • 2
  • 19
  • 25