String filePath=ty.class.getResource("").toString();
//说明:/切换为\\。 \\/中的\\为正则匹配,\\\\中第1、3个为转意字符
String projectPath=filePath.replaceFirst("file:/","").replaceAll("\\/","\\\\");
//browser.download.folderList 设置Firefox的默认 下载 文件夹。0是桌面;1是“我的下载”;2是自定义
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", projectPath);
//使用默认下载路径?总是询问下载位置
//profile.setPreference("browser.download.useDownloadDir", false);
//当一个下载开始时显示下载管理器。true为显示,false为不显示,缺省我true
//profile.setPreference("browser.download.manager.showWhenStarting",false);
//指定无需确认即可下载的文件格式
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream,"
+ " application/vnd.ms-excel, text/csv, application/zip,application/exe");