sorry if this is a simple question but I have been trying for quite a while now is it possible to call a string from one method to another...
Below I want to call the string fileName from the method fileName to fileOutputToFile. I know I can pass it in but I want to call it from fileOutputToFile.
public class outputToFile {
public void fileName(){
String fileName = "Test";
}
public void fileOutputToFile(String hex) throws Exception{
String fileInfo = hex;
try {
PrintWriter out = new PrintWriter(new BufferedWriter(
new FileWriter("myfile.txt", true)));
out.print(fileInfo);
out.print("\n");
out.close();
}catch (IOException e){
}
}
}