Java Tutorial/SWT/Program — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 15:20, 31 мая 2010
Содержание
- 1 17. Execute program
- 2 17. Get all extensions on your system
- 3 17. Launch an HTML file in the default browser
- 4 17. Look up which program to use
- 5 17. Run the appropriate program for that data file and load the data file into the program.
- 6 17. Show the extensions on the system and their associated programs
17. Execute program
import org.eclipse.swt.program.Program;
public class MainClass {
public static void main(String[] args) {
String[] extensions = Program.getExtensions();
for (String s : extensions) {
Program program = Program.findProgram(s);
if(program != null){
//program.execute(s);
}
}
}
}
17. Get all extensions on your system
import org.eclipse.swt.program.Program;
public class MainClass {
public static void main(String[] args) {
String[] extensions = Program.getExtensions();
for(String s: extensions){
System.out.println(s);
}
}
}
.323 .386 .7z .aca .ace .acf .acg .acl .acp .acs .act .acw .ade .adn .adp .ai .aif .aifc .aiff .ani .api .aps .arj .asa .ascx .asf .asm .asmx .asp .aspx .asx .au .AudioCD .avi .aw .bat .bfc .bin .bkf .blg .bmp .bsc .bz .bz2 .c .cab .cat .cda .cdf .cdx .cer .cfg .cgm .chk .chm .clp .cmd .cnf .ru .cpl .cpp .crl .crt .css .csv .CTT .cur .cxx .dat .db .dbg .dcs .dct .def .der .DeskLink .det .dib .dic .dif .diz .dll .dl_ .doc .dochtml .docmhtml .docxml .dos .dot .dothtml .dqy .drv .dsn .dun .dvd .dvr-ms .ecs .edn .elm .emf .eml .epf .eps .etd .exc .exe .exp .ex_ .eyb .fad .fav .fcs .fdf .fdm .ffa .ffl .fft .ffx .fif .fnd .fnt .Folder .fon .frg .ghi .gif .gra .grp .gz .h .hhc .hlp .hol .hpp .hqx .ht .hta .htc .htm .html .htt .htw .htx .hxx .icc .icm .ico .ics .idb .idl .idq .iii .ilk .imc .inc .inf .infopathxml .ini .ins .inv .inx .in_ .ipr .iqy .iso .isp .its .IVF .jar .java .jbf .jfif .jnlp .job .jod .jpe .jpeg .jpg .JS .JSE .key .latex .lex .lha .lib .lnk .local .log .lwv .lzh .m14 .m1v .m3u .mad .maf .mag .mam .man .manifest .MAPIMail .maq .mar .mas .mat .mau .mav .maw .mda .mdb .mdbhtml .mde .mdi .mdn .mdt .mdw .mdz .mgc .mht .mhtml .mid .midi .mmf .mml .mmm .mmw .mov .movie .mp2 .mp2v .mp3 .mpa .mpe .mpeg .mpf .mpg .mpv2 .msc .msg .msi .MSOLAPRole.1 .msp .MsRcIncident .msstyles .MSWMM .mv .mydocs .ncb .ncs .nfo .nick .nk2 .nls .NMW .nsc .nvr .nws .obd .obj .obt .obz .ocx .oc_ .odc .odccubefile .odcdatabasefile .odcnewfile .odctablefile .oft .opc .oqy .oss .ost .otf .otm .p10 .p12 .p7b .p7c .p7m .p7r .p7s .pab .pbk .pcb .pch .pdb .pdf .pds .pdx .pfm .pfx .php3 .pic .pif .pip .pko .pl .plg .pma .pmc .pml .pmr .pmw .pnf .png .pot .pothtml .ppa .ppi .pps .ppt .ppthtml .pptmhtml .prf .ps .psd .pst .psw .pub .pubhtml .pubmhtml .pwz .qds .r00 .r01 .r02 .r03 .r04 .r05 .r06 .r07 .r08 .r09 .r10 .r11 .r12 .r13 .r14 .r15 .r16 .r17 .r18 .r19 .r20 .r21 .r22 .r23 .r24 .r25 .r26 .r27 .r28 .r29 .rat .rc .RDP .reg .res .rev .rle .rmf .rmi .rnk .rpc .rqy .rsp .rtf .rwz .sam .sbr .sc2 .scd .scf .sch .scp .scr .sct .sdb .secstore .sed .shb .shs .shtml .shw .sit .slk .snd .snp .spc .spl .sql .sr_ .sst .stf .stl .stm .swf .sym .sys .sy_ .tar .taz .tbz .tbz2 .tcs .text .tgz .theme .tif .tiff .tlb .tsp .tsv .ttc .ttf .txt .UDL .uls .URL .uu .uue .uxdc .VBE .vbs .vbx .vcf .vcs .vxd .wab .wav .wax .wb2 .wbk .wcs .webpnp .WHT .whtt .wiz .wizhtml .wk4 .wll .wlt .wm .wma .wmd .wmdb .wmf .wmp .wms .wmv .wmx .wmz .wpd .wpg .wpl .wri .wsc .WSF .WSH .wsz .wtx .wvx .x .xbm .xdp .XEN .xevgenxml .xfd .xfdf .xht .xhtml .xix .xla .xlb .xlc .xld .xlk .xll .xlm .xls .xlshtml .xlsmhtml .xlt .xlthtml .xlv .xlw .xlxml .xml .xnk .xsf .xsl .xsn .xst .xxe .z .z96 .zap .ZFSendToTarget .zip
17. Launch an HTML file in the default browser
import org.eclipse.swt.program.Program;
public class MainClass {
public static void main(String[] args) {
Program.launch("index.html");
}
}
17. Look up which program to use
import org.eclipse.swt.program.Program;
public class MainClass {
public static void main(String[] args) {
Program program = Program.findProgram(".html");
program.execute("index.html");
}
}
17. Run the appropriate program for that data file and load the data file into the program.
SWT has a Program class representing programs and their associated extensions.
17. Show the extensions on the system and their associated programs
import org.eclipse.swt.program.Program;
public class MainClass {
public static void main(String[] args) {
String[] extensions = Program.getExtensions();
for (String s : extensions) {
Program program = Program.findProgram(s);
if(program != null){
System.out.println(s+ ":"+program.getName());
}
}
}
}