title: Call String from one method to another in Java
body: <p>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...</p>
  
  <p>Below I want to call the string <code>fileName</code> from the method <code>fileName</code> to <code>fileOutputToFile</code>. I know I can pass it in but I want to call it from <code>fileOutputToFile</code>. </p>
  
  <pre><code>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){
              }
      }
  }
  </code></pre>