Possible Duplicate:
How to create a Java String from the contents of a file
I am making a java program to read a file and to create files for fun. I was wondering how to read from a file and set it to a string variable. Or to convert a scanner variable to a string variable heres part of the coding as an example:
private Scanner x;
private JLabel label;
private String str;
public void openfile(String st){
try{
x = new Scanner(new File(st));
}
catch(Exception e){
System.out.println("Error: File Not Found");
}
}