I am trying to write a code which runs at background and monitors the copy actions for copying a .mp3 file or a folder containing a .mp3 file
{
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
if (cb.isDataFlavorAvailable(DataFlavor.javaFileListFlavor))
{
try {
String name = ""+cb.getData(DataFlavor.javaFileListFlavor);
boolean found = false;
if (name.toLowerCase().endsWith(".mp3]"))
{
System.out.println("Is MP3");
found = true;
}
if (!found)
{
System.out.println("Is not MP3");
}
}
catch(UnsupportedFlavorException ex)
{
ex.printStackTrace();
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
}