Intento llamar a un método de otro método para que me lea un archivo y depuse escriba los resultados en un archivo externo. pero estoy teniendo problema a la hora de llamar al método.
==== Código =====
import java.util.Scanner;
import javax.swing.*;
import java.io.*;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
// Declared class Invie
public class Invie {
// Declared Object Scanner;
static Scanner input = new Scanner(System.in);
// Declaring the metohd menu
// And declaring menu items.
// Declaring variable lisMenu for creating menu
public static void Menu () {
String listMenu = "";
JOptionPane.showMessageDialog(null, "Welcome to Invie App");
do {
listMenu = JOptionPane.showInputDialog(null, "a. Add items\n b. Show items\n c. Remove items\n x. Exit", "Menu", JOptionPane.INFORMATION_MESSAGE);
if (listMenu.equals ("a")) {
JOptionPane.showInputDialog(null, "Upc Number of product:\n", "Addign items", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showInputDialog(null, "Name of product:\n", "Addign items", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showInputDialog(null, "Date of product:\n", "Addign items", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showInputDialog(null, "Quantity Sold of product:\n", "Addign items", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showInputDialog(null, "Items Prices of product:\n", "Addign items", JOptionPane.INFORMATION_MESSAGE);
}
else if (listMenu.equals ("b")) {
JOptionPane.showMessageDialog(null, "Showing items");
}
else if (listMenu.equals ("c")) {
JOptionPane.showConfirmDialog(null,"Are you sure you want to delete a product? ", "Delet the items", JOptionPane.YES_NO_CANCEL_OPTION);
}
else if (listMenu.equals ("x")) {
JOptionPane.showMessageDialog(null, "Thank you for user own system. See it soon!", "Exit!", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
else {
JOptionPane.showMessageDialog(null, "Please try agen.", "Error!", JOptionPane.ERROR_MESSAGE);
}
}while(!listMenu.equals("x"));
}
// Declaring the metohd call name
// And declaring multiple variable
// Reader, fileInput, fileOutput and the array name productNamesList has 50 items
// Adding integer variable matchesCount, date, upcNumber, experDate, quantitySold, itemsPrices
// Collect the data when the user enters the product number
public static void Name (String listMenu) {
FileReader reader;
Scanner fileInput;
PrintWriter fileOutput;
String productNamesList [] = new String [30],
product, strLine;
int matchesCount = 0, date, upcNumber, experDate, quantitySold, itemsPrices;
String namesOfInputFile = JOptionPane.showInputDialog(null, "Name of the input file and add .txt: ");
String namesOfOutputFile = JOptionPane.showInputDialog(null, "Name of the output file and add .txt: ");
// Input try
try {
reader = new FileReader(namesOfInputFile);
fileInput = new Scanner (reader);
while (fileInput.hasNextLine()) {
strLine = fileInput.nextLine();
product = strLine;
upcNumber = Integer.valueOf(strLine);
if (productNamesList.equals("b")) {
productNamesList[matchesCount] = product;
matchesCount += 1;
}
}
fileInput.close();
}catch(IOException error) {
System.out.print("File error " + error);
}
// Output try
try {
fileOutput = new PrintWriter(namesOfOutputFile);
for (int i = matchesCount - 1; i >= 0; i --) {
if (namesOfOutputFile.equals(productNamesList)){
JOptionPane.showMessageDialog(null, productNamesList[i]);
}
}
fileOutput.close();
}catch(IOException error) {
System.out.print("File error " + error);
}
}
// The main function
// Calling the matohd
public static void main(String[] args) {
Invie myMenu = new Invie();
String[] menuList = {"Meet", "Fish", "Cake"};
Menu();
Name(listMenu);
}
}
El Error es el siguiente:
====Error=====
PS C:\Users\herna\Documents\Projecto-Final> javac Invie.java Invie.java:118: error: cannot find symbol Name(listMenu); ^ symbol: variable listMenu location: class Invie 1 error