From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Loading data from text files

Loading data from text files - Java Tutorial

From the course: Data Science for Java Developers

Loading data from text files

- [Instructor] Now that we've seen how to shrink this data down to a more manageable size, The next order of business is, we're going to take a look at how to actually load this data into our Java program as well as represent it in code. So the first thing we're going to do here is we're going to create a new class in our project here. And we're going to call that class something like TextLoader. Basically this TextLoader class is going to contain some methods for helping us load data from text files. And what we're going to do inside this class is we're going to define a static method. We'll call it something like get lines. It's basically going to load all of the lines and so it will be returning a list of strings. It'll return all of the lines from whatever file path we give it. To show you what I mean, we're just going to say public static List<String> and we'll call this method, getLines and it'll take a string…

Contents