I am currently working on an application and I have now read in the csv file and am able to paste it out to the user.
I am now however attempting to delete a single row of the csv file or a "log" as the file is supposed to be a data log.
I have been looking around and everywhere is saying something different I am new to java and this is confusing. I hope the following code is helpful.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package itsystem;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.FileReader;
/**
*
* @author mccoy
*/
public class ITsystem {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException {
//Scanner object created for users input
Scanner sc = new Scanner(System.in);
int selection;
//Loop menu while true
while(true){
System.out.println("Menu : ");
System.out.println("Type any number between 1 and 7");
System.out.println("1)Display the full maintenance log");
System.out.println("2)Create new log entry");
System.out.println("3)Edit an existing log entry");
System.out.println("4)Delete an existing log entry");
System.out.println("5)Summary Management information");
System.out.println("6)Save all edits to log file");
System.out.println("7)Exit");
selection = sc.nextInt();
switch (selection)
{
case 1 :
// Display maintenance log
Scanner scFile = new Scanner(new File("C:\\Users\\mccoy\\Documents\\NetBeansProjects\\ITsystem\\src\\itsystem\\log.csv"));
scFile.useDelimiter(""); //sets the delimiter pattern
while (scFile.hasNext()) //returns a boolean value
{
System.out.print(scFile.next()); //find and returns the next complete token from this scanner
}
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
System.out.println("Exiting Program...");
System.exit(0);
break;
}
}
}
}