title: Variable declaration from one class to another
body: <p>the below codes are working fine(individually) i just want to pass letter[i] value from FindDrive class to Ziputils input file location such that i can zip pendrive data automatically.</p>
  
  <p><strong>FindDrive Class</strong></p>
  
  <pre><code>package com.prosper;
  
  import java.io.File;
  
  
  public class FindDrive
  {
  /**
   * Application Entry Point
   */
  public static void main(String[] args)
      {
      String[] letters = new String[]{ "A", "B", "C", "D", "E", "F", "G", "H", "I"};
      File[] drives = new File[letters.length];
      boolean[] isDrive = new boolean[letters.length];
  
      // init the file objects and the initial drive state
      for ( int i = 0; i &lt; letters.length; ++i )
          {
          drives[i] = new File(letters[i]+":/");
  
          isDrive[i] = drives[i].canRead();
          }
  
       System.out.println("FindDrive: waiting for devices...");
  
       // loop indefinitely
       while(true)
          {
          // check each drive 
          for ( int i = 0; i &lt; letters.length; ++i )
              {
              boolean pluggedIn = drives[i].canRead();
  
              // if the state has changed output a message
              if ( pluggedIn != isDrive[i] )
                  {
                  if ( pluggedIn ){
                      System.out.println("Drive "+letters[i]+" has been plugged in");
                  }
                  else
                      System.out.println("Drive "+letters[i]+" has been unplugged");
  
                  isDrive[i] = pluggedIn;
                  }
              }
  
  
          // wait before looping
          try { Thread.sleep(100); }
          catch (InterruptedException e) { /* do nothing */ }
  
          }
      }
  
  }
  </code></pre>
  
  <p><strong>The ZipUtils Class</strong></p>
  
  <pre><code>package com.prosper;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.zip.ZipEntry;
  import java.util.zip.ZipOutputStream;
  
  public class ZipUtils {
  
      private List &lt;String&gt; fileList;
      private static final String OUTPUT_ZIP_FILE = "E:\\appu\\Folder.zip";
      private static final String SOURCE_FOLDER = "E:\\appu\\"; //SourceFolder 
  
      public ZipUtils() {
          fileList = new ArrayList &lt; String &gt; ();
      }
  
      public static void main(String[] args) {
          ZipUtils appZip = new ZipUtils();
          appZip.generateFileList(new File(SOURCE_FOLDER));
          appZip.zipIt(OUTPUT_ZIP_FILE);
      }
  
      public void zipIt(String zipFile) {
          byte[] buffer = new byte[1024];
          String source = new File(SOURCE_FOLDER).getName();
          FileOutputStream fos = null;
          ZipOutputStream zos = null;
          try {
              fos = new FileOutputStream(zipFile);
              zos = new ZipOutputStream(fos);
  
              System.out.println("Output to Zip : " + zipFile);
              FileInputStream in = null;
  
              for (String file: this.fileList) {
                  System.out.println("File Added : " + file);
                  ZipEntry ze = new ZipEntry(source + File.separator + file);
                  zos.putNextEntry(ze);
                  try {
                      in = new FileInputStream(SOURCE_FOLDER + File.separator + file);
                      int len;
                      while ((len = in .read(buffer)) &gt; 0) {
                          zos.write(buffer, 0, len);
                      }
                  } finally {
                      in.close();
                  }
              }
  
              zos.closeEntry();
              System.out.println("Folder successfully compressed");
  
          } catch (IOException ex) {
              ex.printStackTrace();
          } finally {
              try {
                  zos.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
      public void generateFileList(File node) {
          // add file only
          if (node.isFile()) {
              fileList.add(generateZipEntry(node.toString()));
          }
  
          if (node.isDirectory()) {
              String[] subNote = node.list();
              for (String filename: subNote) {
                  generateFileList(new File(node, filename));
              }
          }
      }
  
      private String generateZipEntry(String file) {
          return file.substring(SOURCE_FOLDER.length() + 1, file.length());
      }
  }
  </code></pre>