课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Input and output - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Solution: Input and output
(electronic music) - So let's have a go at fixing these unit tests one by one. So the first test is called test getFirstLine and this one is expecting to get back the first line from the file. So if I run this test, at the moment this one fails, because it's returning just an empty string, but it's expecting that first line. So this test is calling a method called getFirstLine inside the file reader exercise class. So let's have a look at that method. So here's the FileReaderExercise class, and the get first line method just creates an empty string called firstLine and then just returns that variable. So we want to actually return the first line of the file. So I'm going to add BufferedReader and I'll call it reader. Then I can say = new BufferedReader. And then inside this constructor, I'm going to pass in a new file reader. So I'm going to say newFileReader. And then inside this constructor, I pass in the path…