Icon icon=fsv.getSystemIcon(new File(pathload));
ImageIcon imageIcon = (ImageIcon)icon;
Image image = imageIcon.getImage();
BufferedImage bi = new BufferedImage(icon.getIconWidth()*10,icon.getIconHeight()*10,BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.drawImage(image,0,0,null);
g2d.dispose();
try{
ImageIO.write(bi,"png",new File("D:/k.png"));
}catch(IOException e){
e.printStackTrace();
}
通过绝对的文件路径pathload 获取它的系统图标,并在D盘创建k.png文件存储