コード例 #1
0
 private void innerGet(String path, HttpServletResponse response) throws IOException {
   path = path.replace("/static/", "");
   if (FilenameUtils.isExtension(path, "js")) {
     path = "js/" + path;
     response.setContentType("text/javascript; charset=UTF-8");
   } else if (FilenameUtils.isExtension(path, "css") || FilenameUtils.isExtension(path, "less")) {
     path = "css/" + path;
     response.setContentType("text/css; charset=UTF-8");
   } else if (FilenameUtils.isExtension(path, IMG_EXTENSION)) {
     path = "img/" + path;
     response.setContentType("image/" + FilenameUtils.getExtension(path));
   }
   path = "view/" + path;
   if (path.endsWith(".handlebars.js")) {
     // handlebars
     response.setContentType("text/javascript; charset=UTF-8");
     path = path.substring(0, path.length() - 3);
     File file = new File(getWebInf(), path);
     String content = FileUtils.readFileToString(file, "UTF-8");
     try {
       content = HandlebarsObj.toJavaScript(content);
       IOUtils.write(content.getBytes("UTF-8"), response.getOutputStream());
     } catch (Exception e) {
       throw new ServerError(e);
     }
   } else {
     sendFile(response, path);
   }
 }
  private List<Path> findAvroFilesInDirs(List<Path> dirs, FileSystem fs)
      throws FileNotFoundException, IOException {
    List<Path> files = Lists.newArrayList();

    for (Path dir : dirs) {
      for (FileStatus status : HadoopUtils.listStatusRecursive(fs, dir)) {
        if (FilenameUtils.isExtension(status.getPath().getName(), AVRO)) {
          files.add(status.getPath());
        }
      }
    }
    return files;
  }
コード例 #3
0
  /*
   * Copy all entries that are a JAR file or a directory
   */
  private static void copyValidClasspathEntries(Collection<URL> source, Set<URL> destination) {
    String fileName;
    boolean isJarFile;
    boolean isDirectory;

    for (URL url : source) {
      if (destination.contains(url)) {
        continue;
      }

      fileName = url.getFile();
      isJarFile = FilenameUtils.isExtension(fileName, "jar");
      isDirectory = new File(fileName).isDirectory();

      if (isJarFile || isDirectory) {
        destination.add(url);
      } else if (logger.isDebugEnabled()) {
        logger.debug("Ignored classpath entry: " + fileName);
      }
    }
  }
コード例 #4
0
 /**
  * Indicates if the current file is of type archive.
  *
  * @param filename the name of the file.
  * @return true is the file s of type archive - false otherwise.
  */
 public static boolean isImage(final String filename) {
   return FilenameUtils.isExtension(filename, ImageUtil.IMAGE_EXTENTIONS);
 }
コード例 #5
0
ファイル: Landing.java プロジェクト: shuixi2013/show-java
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == FILE_PICKER) {
      if (data != null) {

        Uri uri = data.getData();
        File apkFile = new File(uri.getPath());
        final String PackageDir = apkFile.getAbsolutePath();

        Ln.d(PackageDir);

        final String PackageName;
        final String PackageId;

        if (FilenameUtils.isExtension(PackageDir, "apk")) {
          PackageManager pm = getPackageManager();
          PackageInfo info = pm.getPackageArchiveInfo(PackageDir, PackageManager.GET_ACTIVITIES);
          if (info != null) {
            ApplicationInfo appInfo = info.applicationInfo;

            if (Build.VERSION.SDK_INT >= 8) {
              appInfo.sourceDir = PackageDir;
              appInfo.publicSourceDir = PackageDir;
            }
            PackageName = info.applicationInfo.loadLabel(getPackageManager()).toString();
            PackageId = info.packageName;

          } else {
            PackageName = "";
            PackageId = "";
          }

          if (!prefs.getBoolean("hide_decompiler_select", false)) {
            final CharSequence[] items = {"CFR 0.102", "JaDX 0.6.1"};
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Pick a decompiler");
            builder.setItems(
                items,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int item) {
                    Intent i = new Intent(getApplicationContext(), AppProcessActivity.class);
                    i.putExtra("package_id", PackageId);
                    i.putExtra("package_label", PackageName);
                    i.putExtra("package_file_path", PackageDir);
                    i.putExtra("decompiler", (item == 1 ? "jadx" : "cfr"));
                    startActivity(i);
                    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
                  }
                });
            AlertDialog alert = builder.create();
            alert.show();
          } else {
            Intent i = new Intent(getApplicationContext(), AppProcessActivity.class);
            i.putExtra("package_id", PackageId);
            i.putExtra("package_label", PackageName);
            i.putExtra("package_file_path", PackageDir);
            i.putExtra("decompiler", prefs.getString("decompiler", "cfr"));
            startActivity(i);
            overridePendingTransition(R.anim.fadein, R.anim.fadeout);
          }
        }
      }
    }
  }
コード例 #6
0
 @Test
 public void testExtension() {
   System.out.println(new File("tangara.jar").getName());
   assertTrue(FilenameUtils.isExtension(new File("tangara.jar").getName().toLowerCase(), "jar"));
   assertTrue(FilenameUtils.isExtension(new File("tangara.JAR").getName().toLowerCase(), "jar"));
 }
コード例 #7
0
 /**
  * 验证文件类型
  *
  * @param file 文件
  * @param extensions 扩展名集合
  * @return 验证结果
  */
 public static boolean isExtension(File file, Collection<String> extensions) {
   return FilenameUtils.isExtension(file.getName(), extensions);
 }
コード例 #8
0
 /**
  * 验证文件类型
  *
  * @param file 文件
  * @param extension 扩展名
  * @return 验证结果
  */
 public static boolean isExtension(File file, String... extensions) {
   return FilenameUtils.isExtension(file.getName(), extensions);
 }
コード例 #9
0
ファイル: MediaFile.java プロジェクト: AnjinMeili/subsonic
 private static boolean isVideoFile(File file) {
   return FilenameUtils.isExtension(
       file.getName(), ServiceLocator.getSettingsService().getVideoFileTypesAsArray());
 }