code: public Node uploadFile( Session session,
                              String path,
                              File file ) throws RepositoryException, IOException {
          isNotNull(session, "session");
          isNotNull(path, "path");
          isNotNull(file, "file");
  
          if (!file.exists()) {
              throw new IllegalArgumentException("The file \"" + file.getCanonicalPath() + "\" does not exist");
          }
          if (!file.canRead()) {
              throw new IllegalArgumentException("The file \"" + file.getCanonicalPath() + "\" is not readable");
          }
          // Determine the 'lastModified' timestamp ...
          Calendar lastModified = Calendar.getInstance();
          lastModified.setTimeInMillis(file.lastModified());
  
          // Open the URL's stream first ...
          InputStream stream = new BufferedInputStream(new FileInputStream(file));
          return uploadFile(session, path, stream);
      }
docs: Upload the content in the supplied file into the repository at the defined path, using the given session. This method will
  create a 'nt:file' node at the supplied path, and any non-existant ancestors with nodes of type 'nt:folder'. As defined by
  the JCR specification, the binary content (and other properties) will be placed on a child of the 'nt:file' node named
  'jcr:content' with a node type of 'nt:resource'.
  
  @param session the JCR session
  @param path the path to the file
  @param file the existing and readable file to be uploaded
  @return the newly created 'nt:file' node
  @throws RepositoryException if there is a problem uploading the file
  @throws IOException if there is a problem using the stream
  @throws IllegalArgumentException if the file does not exist or is not readable
  @throws IllegalArgumentException is any of the parameters are null