[Solved] How to read txt file and save as a single string in java in order to split it by a certain character [closed]


Files#lines returns a stream of all the lines in the file. You could join these lines to a single string, and then split it according to the separator:

String separator = ":"; // for example...
String entireFile = 
    Files.lines(Paths.get("file.txt")).collect(Collectors.joining());
String[] separated = entireFile.split(separator);

solved How to read txt file and save as a single string in java in order to split it by a certain character [closed]