processbuilder - Using process builder to open a file in internet explorer Java -


i have program have written java @ work takes xml , allows users view xml in table form, make changes, save table new xml.

everything finished except 1 small detail. once user saves table data of course parsed new xml. want dialog appear tells user save location , asks if open file.

if user clicks yes want xml open in internet explorer. had implemented similar approach processbuilder in program in case file needed open notepad worked perfectly.

now issue i'm having while internetexplorer open file not open, browser stay on home page. i'll post code below if can me i'd appreciate it!

location = "//camt54revised"+date+".xml";             location = fhandling.savefile.getselectedfile()+location;              transformerfactory transformerfactory = transformerfactory.newinstance();             transformer transformer = transformerfactory.newtransformer();             domsource source = new domsource(doc);             streamresult result = new streamresult(new file(location));             transformer.transform(source, result);              int dialogresult = joptionpane.showconfirmdialog(null, "output file saved "+location+". view file?","display output",joptionpane.yes_no_option);             if(dialogresult==joptionpane.yes_option){                  processbuilder pb = new processbuilder("c:\\program files\\internet explorer\\iexplore.exe", location);                 try{                     pb.start();                 }catch(ioexception e){                     e.printstacktrace();                 }              } 

supposing internet explorer default browser, can use desktop api matter.

public class desktoptest {      public static void main(string args[]) {          if (!desktop.isdesktopsupported()) {             system.err.println("desktop not supported!");             system.exit(-1);         }          desktop desktop = desktop.getdesktop();         file file = new file(args[0]);          if (desktop.issupported(desktop.action.open)) {             try {                 desktop.open(file);             }             catch (ioexception ioe) {                 system.err.println("unable open: " + file.getname());             }         }     } } 

but if want force internet explorer, have resort process builder anyways.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -