📄 extensionfilefilter.java
字号:
package org.jawin.browser.util;
import java.io.File;
import javax.swing.filechooser.FileFilter;
import java.util.HashMap;
/**
* Filters files using their extensions
*
* <p>Title: Jawin Code Generation GUI</p>
* <p>Description: GUI for exploring type libraries and generating Java code</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Open Source Incentive</p>
*
* @author Josh Passenger
* @version 1.0
*/
public class ExtensionFileFilter extends FileFilter
{
private String description = null;
private HashMap extensions = new HashMap();
public ExtensionFileFilter(String newDescription)
{
description = newDescription;
}
public void addExtension(String newExtension)
{
extensions.put(newExtension, newExtension);
}
public String getDescription()
{
return description;
}
public boolean accept(File file)
{
if (file.isDirectory())
{
return true;
}
if (extensions.containsKey(getExtension(file)))
{
return true;
}
else
{
return false;
}
}
private String getExtension(File file)
{
String fileName = file.getName();
return getExtension(fileName);
}
private String getExtension(String fileName)
{
int lastDot = fileName.lastIndexOf('.');
if (lastDot < 0)
{
return "";
}
return fileName.substring(lastDot).toLowerCase();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -