Question: CSIS 2420. I need help writting this. I wrote a program for it but it keeps saying my file doesn't exist but the csv file

CSIS 2420. I need help writting this. I wrote a program forCSIS 2420.

I need help writting this. I wrote a program for it but it keeps saying my file doesn't exist but the csv file is in the source folder? My code is below as well as a description of the project.

package books;

import java.io.InputStream;

import java.util.Collections;

import java.util.Comparator;

import java.util.List;

public class BookApp {

public static void main(String[] args){

List b = Book.getList("src/books");

System.out.println();

System.out.println("Sorted List:");

Collections.sort(b);

for(Book books: b){

System.out.println(books.toString());

}

Comparator c = Collections.reverseOrder();

Collections.sort(b, c);

System.out.println();

System.out.println("Reversed Order:");

for(Book books: b){

System.out.println(books.toString());

}

}

}*/

package books;

import java.io.File;

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Collections;

import java.util.List;

import java.util.Scanner;

public class Book implements Comparable {

private String title;

private String author;

private int year;

public Book(String title, String author, int year){

this.title=title;

this.author=author;

this.year=year;

}

public String getTitle(){

return title;

}

public String getAuthor(){

return author;

}

public int getYear(){

return year;

}

@Override

public String toString(){

return title + " by " + author +"("+year+")";

}

public static List getList(String f){

List books = new ArrayList();

int bookNum = 0;

File file = new File("books.csv");

Scanner input;

try {

input = new Scanner(file);

while(input.hasNext()){

String[] parts = input.nextLine().split(",");

if(parts.length==3){

Book b = new Book(parts[0],parts[1],Integer.parseInt(parts[2]));

books.add(b);

bookNum++;

}else{

System.out.println("Problem reading in : "+ Arrays.toString(parts).replace("[","").replace("]", ""));

}

}

input.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

}

System.out.println("Number of books: "+ bookNum);

return books;

}

@Override

public int compareTo(Book o) {

return this.getTitle().compareTo(o.getTitle());

}

}*/

it but it keeps saying my file doesn't exist but the csv

file is in the source folder? My code is below as well

2014 2013 The Goldfinch The Orphan Master's Son No Pulitzer prize for fiction was awarded in 2012 A Visit from the Goon Squad Tinkers Olive Kitteridge The Brietf The Road March Gilead The Known World Middlesex Empire Falls The Amazing Adventures of Kavalier & Clay Interpreter of Maladies The Hours Donna Tartt Adam Johnson Jennifer Egan Paul Harding Elizabeth Strout Wondrous Life of Oscar Wao Junot Diaz Cormac McCa Geraldine Brooks Marilynne Robinson Edward P. Jones Jeffrey Eugenides Richard Russo Michael Chabon Jhumpa Lahiri Michael Cunningham 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!