展开全部
百分之百可用,只限jdk1.4用不了,会报错。本人试了,jdk1.6可以使用
public static void main(String[] args) throws Exception {
File file = new File( "D:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe"); \\提取图标的应用程序
OutputStream inStream = new FileOutputStream(new File("c:\\45.png")); \\图标保存地址
try {
BufferedImage www = (BufferedImage)((ImageIcon) toIcon(file)).getImage();
ImageIO.write(www, "png", inStream);
inStream.flush();
inStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Icon toIcon(File file) throws FileNotFoundException {
ShellFolder shellFolder = ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(shellFolder.getIcon(true));
return icon;
}
public static void main(String[] args) throws Exception {
File file = new File( "D:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe"); \\提取图标的应用程序
OutputStream inStream = new FileOutputStream(new File("c:\\45.png")); \\图标保存地址
try {
BufferedImage www = (BufferedImage)((ImageIcon) toIcon(file)).getImage();
ImageIO.write(www, "png", inStream);
inStream.flush();
inStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Icon toIcon(File file) throws FileNotFoundException {
ShellFolder shellFolder = ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(shellFolder.getIcon(true));
return icon;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询