public static void copy(String inFile, String outFile, int lineCount) throws IOException {
        BufferedReader reader = null;
        BufferedWriter writer = null;

        try {
            reader = createReader(inFile);
            writer = createWriter(outFile, false);
            int c;

            int newLines = 0;
            while (-1 != (c=reader.read()) && newLines<lineCount) {
                writer.write(c);
                if (c=='\n')
                    newLines++;
            }
        } finally {
            closeReader(reader);
            closeWriter(writer);
        }
    }
Copies the n first lines of a file to another file.
If the out file exists it will be overwritten

@throws IOException if copying fails
vespajlib/src/main/java/com/yahoo/io/IOUtils.java