import java.util.List;
public class TabularClipboardDataHelper {
public static List<List<String>> getTabularDataFromClipboard() {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
DataFlavor flavors[] = cb.getAvailableDataFlavors();
if (flavors == null)
return null;
DataFlavor html = searchForFlavor(flavors, "text/html",
"java.lang.String");
if (html != null) {
try {
String data = (String) cb.getData(html);
return HtmlTableParser.parseTable(data, true);
} catch (Exception e) {
return null;
}
}
DataFlavor text = searchForFlavor(flavors, "text/plain",
"java.lang.String");
if (text != null) {
try {
String data = (String) cb.getData(text);
if (HtmlTableParser.containsHtmlTableData(data))
return HtmlTableParser.parseTable(data, true);
else
return parseTabDelimitedData(data);
} catch (Exception e) {