The thing which you seem to be missing is an understanding of types. Basically, a type is the set of things that you can do a particular set of actions to. For instance, I can throw a ball, but cannot throw a truck. So, ball.throw() is sensible but truck.throw() is not. Balls and trucks are therefore not of the same type. Any two things which you can do the same actions to are of the same type.
In Java, types boil down to classes and interfaces. An interface is a general type, something like "can be thrown" whereas a class is a specific type "something like Basketball".
So, lets apply this to your code. Files is a class which contains static functions for dealing with files. ReadAllLines is a function which returns a List of Strings (the lines of the file) which, being a List, can be converted to a Stream using the stream method which you can (but should not) turn into an array using toArray. (Lists are generally similar to but preferable to arrays.) So a better bit of code that does what you are doing there would be:
Code:
List<String> data = Files.readAllLines(Paths.get(filename));
readString, on the other hand, reads the entire contents of the file into a single string. As such, it doesn't make sense to try and stream() it. After all, you don't have a list of lines, but instead just one long string. Also, this means that it doesn't make sense to map it. It is, again, just one string. So, let's play around with some code.
Code:
First, let's do what you did to the first one.
String[] data = Files.readString(Paths.get(fileName))
.split('\n')
.stream() // this line is unnecessary, as Lists can also be toArrayed.
.toArray(String[] ::new);
Again, this would be better as:
List<String> data = Files.readString(Paths.get(fileName)).split('\n');
Now moving on to what you want done:
String input = Files.readString(Paths.get(filename))
.replaceAll("^\t+" ""); // note the regular expression,
// this matches one or more tabs
// at the beginning of a line.
// If you only want to remove 1 tab,
// remove the '+'.
or
List<String> data = Files.readAllLines(Paths.get(filename))
.stream()
.map(l -> l.replaceAll("^\t+", ""))
.collect(Collectors.toList());
And, of course, if getting a single string out matters (I am
not sure that is something you should want)
List<String> data = Files.readAllLines(Paths.get(filename))
.stream()
.map(l -> l.replaceAll("^\t+", ""))
.collect(Collectors.joining('\n'));
Sidenote, I am reminded why I hate Java*. They add a whole bunch of unnecessary bullshit where I have to convert between a List and a Stream because for some reason a List can't be a Stream (the reason is because of Java's type system, but still, I hates it). That would all have required so much less boilerplate in Kotlin.