ole1990 0 Posted February 2, 2011 Report Share Posted February 2, 2011 Bom dia, queria passar o conteúdo de um ficheiro para uma string só que da-me um erro nesta linha " Scanner finput = new Scanner(new File(nomeficheiro)); " Alguém me consegue explicar o porquê? import java.io.File; import java.io.FileNotFoundException; import java.util.Formatter; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; public class metodos { public static String passarparastring() { System.out.println("Insira o nome do ficheiro"); String frasea= "", nomeficheiro=""; nomeficheiro="exemploa.txt"; Scanner finput = new Scanner(new File(nomeficheiro)); while (finput.hasNext()) { frasea += finput.nextLine(); } return frasea; } } Link to post Share on other sites
brunoais 65 Posted February 2, 2011 Report Share Posted February 2, 2011 Posso saber ou não dependendo do erro que é. "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%. Link to post Share on other sites
Diogo M 0 Posted February 2, 2011 Report Share Posted February 2, 2011 public static String passarparastring() throws FileNotFoundException { .... } Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now