Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Reading a file line-by-line in reverse order is fundamentally tricky.

It's not too bad if you've got a fixed width encoding. It's feasible if you've got a variable width encoding which you can detect the first byte of etc (e.g. UTF-8). It's virtually impossible to do efficiently if the encoding is variable width with no sensible way of determining boundaries (or if it uses "shifting" for example).

I have an implementation in C# in another questionin another question, but it would take a fair amount of effort to port that to Java.

Reading a file line-by-line in reverse order is fundamentally tricky.

It's not too bad if you've got a fixed width encoding. It's feasible if you've got a variable width encoding which you can detect the first byte of etc (e.g. UTF-8). It's virtually impossible to do efficiently if the encoding is variable width with no sensible way of determining boundaries (or if it uses "shifting" for example).

I have an implementation in C# in another question, but it would take a fair amount of effort to port that to Java.

Reading a file line-by-line in reverse order is fundamentally tricky.

It's not too bad if you've got a fixed width encoding. It's feasible if you've got a variable width encoding which you can detect the first byte of etc (e.g. UTF-8). It's virtually impossible to do efficiently if the encoding is variable width with no sensible way of determining boundaries (or if it uses "shifting" for example).

I have an implementation in C# in another question, but it would take a fair amount of effort to port that to Java.

Source Link
Jon Skeet
  • 1.5m
  • 893
  • 9.3k
  • 9.3k

Reading a file line-by-line in reverse order is fundamentally tricky.

It's not too bad if you've got a fixed width encoding. It's feasible if you've got a variable width encoding which you can detect the first byte of etc (e.g. UTF-8). It's virtually impossible to do efficiently if the encoding is variable width with no sensible way of determining boundaries (or if it uses "shifting" for example).

I have an implementation in C# in another question, but it would take a fair amount of effort to port that to Java.