public static void main(String[] args) {
        Locale.setDefault(Locale.US);
        HashSet<Product> products = new HashSet<>();
        BigDecimal totalAmount = BigDecimal.ZERO;

        //Read products list from file
        try (BufferedReader readProducts = new BufferedReader(new FileReader("..\\products2.txt"))) {
            String line = readProducts.readLine();
            while (line != null) {
                String[] prod = line.split(" ");
                products.add(new Product(prod[0], BigDecimal.valueOf(Double.parseDouble(prod[1]))));

                line = readProducts.readLine();
            }

        } catch (IOException ex) {
            Logger.getLogger(Task10ProductsOrder.class.getName()).log(Level.SEVERE, null, ex.getMessage());
        }

        //Read orders list from file
        try (BufferedReader readOrders = new BufferedReader(new FileReader("..\\order2.txt"))) {
            String line = readOrders.readLine();
            while (line != null) {
                String[] orders = line.split(" ");

                for (Product prod : products) {
                    if (prod.getName().equals(orders[1])) {
                      totalAmount=  totalAmount.add(prod.getPrice().multiply(BigDecimal.valueOf(Double.parseDouble(orders[0]))));
                    }
                }
                line = readOrders.readLine();
            }
        } catch (IOException ex) {
            Logger.getLogger(Task10ProductsOrder.class.getName()).log(Level.SEVERE, null, ex);
        }

        //System.out.println(totalAmount);
        
        //Write to output file
        try (BufferedWriter wr=new BufferedWriter(new FileWriter("..\\output.txt"))){
            wr.write(totalAmount.toString());
        } catch (IOException ex) {
            Logger.getLogger(Task10ProductsOrder.class.getName()).log(Level.SEVERE, null, ex);
        } 
        
    }