I have in a class called Entrance the following program:
public class Entrada {
public static void main(String[]args) throws IOException{
Scanner lector = new Scanner (System.in);
String fichero ;
System.out.println("Posa el nom del ficher:");
fichero = lector.nextLine();
File file = new File(fichero);
EscriureLlibreria(fichero);
}
How can I pass the file value to the Sort class?
public class Sortida {
public static void main(String[] args) {
try {
JAXBContext context = JAXBContext.newInstance(Llibreria.class);
Unmarshaller ums = context.createUnmarshaller();
// Mostrem el fitcher creat previament a la clase Entrada.
Entrada.EscriureLlibreria(fichero);
JAXBElement<Llibre> rootElementCast = ums.unmarshal(new StreamSource(new File(fichero)), Llibre.class);
//Mostrem totes les característiques que hem demanat per teclat.
Llibre llibreria = rootElementCast.getValue();
System.out.println("Autor:" + llibreria.getAutor());
System.out.println("Nom" + llibreria.getNom());
System.out.println("Editorial" + llibreria.getEditorial());
System.out.println("ISBN:" + llibreria.getIsbn());
} catch (JAXBException e) {
e.printStackTrace();
}
}
}
With file value I refer to Public Class Entry { inside the main I get a value that is the file.
The value is that it gives me a file entered by the user, because that value I want it in:
public class Sortida {
inside your main to use it to read it.
something like this:
Entry.EscriureLlibreria ( file ); JAXBElement rootElementCast = ums.unmarshal (new StreamSource (new File ( file )), Llibre.class);