Reading multiple data types in a file and storing it in a linked list C++

Hi, how do you read multiple data types in a file and storing it in a linked list. I read the items with no linked list but when I used linked list it doesnt work. I think there is something wrong in my code. Programming language: C++ Thank you

struct Video {
    int videoID;
    string movieTitle;
    string movieGenre;
    string movieProduction;
    int numberOfCopies;

};



class videoList {
    private:
        struct videoNode {
            Video video;
            struct videoNode *next;
        };
        videoNode *head;

    public:
        videoList(); //constructor
        //~videoList(); //deconstructor
        void insertNewVideo (Video vid);
        void rentVideo (Video vid);
        void returnVideo (Video vid);
        void showVideoDetails (Video vid);
        void displayVideo ();
        bool isVideoExist();
        void exit ();
        void generateVideoID();
        void readVideoFile();
};



void videoList::readVideoFile () {
    videoNode *nodePtr;
    ifstream file( "videoList.txt" ) ;
    string line ;
    string id, movieTitle, movieGenre, movieProduction, numberOfCopies;

    if (!file) {
        cout << endl << "\t\t\t\t There is file!" << endl;
    }
    else {
        std::stringstream linestream(line);
        cout << endl << "\t\t\t\t Movie List " << endl; 
        nodePtr = head;

        while (nodePtr)
            while (getline(file, line)){
    {


        std::getline(linestream, id, ',');
        std::getline(linestream, nodePtr->video.movieTitle, ',');
        std::getline(linestream, nodePtr->video.movieGenre, ',');
        std::getline(linestream, nodePtr->video.movieProduction, ',');
        linestream >> nodePtr->video.numberOfCopies;

        if(linestream) // true if there were no errors reading the stream
        {
            std::cout << id << '\n';
            std::cout << nodePtr->video.movieTitle << '\n';
            std::cout << nodePtr->video.movieGenre << '\n';
            std::cout << nodePtr->video.movieProduction << '\n';
            std::cout << nodePtr->video.movieTitle << '\n';
        }
    }
}
}
}

Exception handling in java (Looping in menu)

Hi Experts,

I want to ask if there is a way if the user input a character it will handle an exception and go back again to the menu but in my code it wont go back to the menu. Thank you

public class main {
    public static void main(String[] args){

            int choice = 0;
        Scanner input = new Scanner(System.in);
        boolean isValidChoice = false;

        Admin adminObject = new Admin();
        Cashier cashierObject = new Cashier();
        do {
            try {
            System.out.println("1. Admin");
            System.out.println("2. Cashier");
            System.out.println("3. Exit");

            System.out.print("Please Enter Required Option from 1 - 6: ");
            if(input.hasNextInt()){
           choice= input.nextInt(); 
           isValidChoice = true;
       }
            choice = input.nextInt();
            System.out.println("");

            switch (choice) {
                case 1:
                    adminObject.Admin();
                    break;
                case 2:
                    cashierObject.Cashier();
                    break;
            }

        } catch (Exception e){
               System.out.println("Please use valid input."); 
         }
        } while (choice != 0);

    }
}

Java – Collection with File Handling and

Hi Experts,

Appreciate your help or advise as I am stuck.

The user will input all of the objects (like name, gender, age) into the system. Once, user input it will write to a file.
The program should only handle file handling. is my program correct? Thank you in advance

import java.util.*;
import java.text.*;
import java.io.*;
 import java.util.Scanner;

public class Sample {

    public static void main(String[] args) {
        //if (args.length < 1) {
         //   System.out.println("Please provide output file");
        //    System.exit(0);
      //  }

       // String outputFile = args[0];

        DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");

        try (
            BufferedWriter groceryFile = new BufferedWriter(new FileWriter("grocery.txt", true))) {
            Scanner input = new Scanner(System.in);

            Set<Student> listStudent = new HashSet<>();
            Student student = new Student();
            System.out.println("Student name");
            Student.setName(input.nextLine());

            listStudent.add(
                new Student("Mike", dateFormat.parse("01-15-1998"), false, 40, 80.5f));



            for (Student student : listStudent) {
                groceryFile.write(student.getName());
            }

        } catch (IOException | ParseException ex) {
            ex.printStackTrace();
        }
    }

Removing Duplicates – Java

Hi Experts,

I have a question. I have an object and want to insert in a text file. Before inserting, I want to check if it is duplicate. If no duplicate is found, I will insert the object. If yes, will not insert an object? Do I need a collection for this? This is for Java. Thank you!

FileHandling Java

Hi,

I would like to ask regarding File Handling in Java. I am creating a program for my school project and we should use file handling only (.txt) not database. When I add a product (with product code, product name, price, etc), I want to save it in a file. After that there is an option for displaying the product. I would like to display the product in a columnar format. Can you advice me on how I can do it? or once the program reads the file, is there a way to separate the identifiers so I can format each identifiers before displaying in the system. Thank you experts