static Icon getIconForFile(GFile file, TaskMonitor monitor) throws CancelledException {
		try {
			GFileSystem fs = file.getFilesystem();
			if (fs instanceof GIconProvider iconProviderFS) {
				return iconProviderFS.getIcon(file, monitor);
			}

			try (InputStream is = file.getFilesystem().getInputStream(file, monitor)) {
				Image image = ImageIO.read(is);
				if (image == null) {
					return null;
				}
				return new ImageIcon(image);
			}
			catch (Exception e) {
				Msg.error(GIconProvider.class, "Exception while reading image " + file.getName(),
					e);
			}
		}
		catch (IOException ioe) {
			// ignore
		}
		return null;
	}
Helper static method that will get an Icon from a data file.

@param file {@link GFile} to read and convert into an Icon.
@param monitor {@link TaskMonitor} to watch and update with progress.
@return new {@link Icon} instance with contents of the GFile, or null if the
file couldn't be converted into an image.
@throws CancelledException if the user cancels.
Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GIconProvider.java