You actually get line 8 by file($file). And you can use the Apache commons-io library to do the same function. The PHP file() and file_get_contents() functions are just shortcut methods of fopen() + fgets()/stream_get_contents() + fclose(). In Java, with Apache commons IO, you can also use IOUtils.toString(new FileInputStream(file)), which has the same function. On the other hand, beginners should actually use things like FileInputStream or BufferedReader so that they actually know what the machine is actually doing. Any real programmer should know what is happening inside the machine, rather than just looking at the results. Now, stop getting off-topic. To discuss it, let's go to another thread.