Getting Icon from file:
ImageIcon icon = new ImageIcon(filename);
buffered copying of file:
private void copyFile(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
}
in.close();
out.close();
}
reading/writing of images from/to file is done by ImageIO class
hi,
Sorry about my bad english.
I only want the displayed Icon for a file from the filesystem stored in an other file or in a database.
So i think, i need to convert the icon to an image and the imate to a bytestream or bytearray.
But i don't know how to get the image from the icon.
thank you
andreas
Something along these lines
Icon i = fileSystemView.getSystemIcon(f);
BufferedImage bi = new BufferedImage(i.getIconWidth(), i.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
i.paintIcon(null, g, 0, 0);
g.dispose();
Then use ImageIO to convert the image to your chosen format.