Java Valid Lines