1.eclipse自带
输出 sysout,syserr,systrace
main main
变量 new,cast
还有很多,发现好用的持续添加
2.自定义
${:import(java.util.Map.Entry)} for(Entry<${key:argType(map,0)},${value:argType(map,1)}> entry : ${map:var(java.util.Map)}.entrySet()) { ${key} key = entry.getKey(); ${value} value = entry.getValue(); ${cursor} }
${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)} /** * Logging mechanism. */ private static Logger logger = LoggerFactory.getLogger(${enclosing_type}.class);
${:import(java.io.BufferedReader, java.io.FileNotFoundException, java.io.FileReader, java.io.IOException)} BufferedReader in = null; try { in = new BufferedReader(new FileReader(${fileName})); String line; while ((line = in.readLine()) != null) { ${cursor} } } catch (FileNotFoundException e) { // Handle exception } catch (IOException e) { // Handle exception } finally { if(in != null) in.close(); }
${:import(java.nio.file.Files, java.nio.file.Paths, java.nio.charset.Charset, java.io.IOException, java.io.BufferedReader)} try (BufferedReader in = Files.newBufferedReader(Paths.get(${fileName:var(String)}), Charset.forName("UTF-8"))) { String line = null; while ((line = in.readLine()) != null) { ${cursor} } } catch (IOException e) { // ${todo}: handle exception }
${:import(java.nio.file.Files, java.nio.file.Paths, java.nio.Charset, java.io.IOException, java.io.BufferedWriter)} try (BufferedWriter out = Files.newBufferedWriter(Paths.get(${fileName:var(String)}), Charset.forName("UTF-8"))) { out.write(${string:var(String)}); out.newLine(); ${cursor} } catch (IOException e) { // ${todo}: handle exception }
${:import(org.testng.annotations.Test, org.testng.annotations.Parameters, org.testng.Assert)} @Test(groups = "${name}") public final void ${name}() { ${cursor} }
${:import (org.junit.Before)} @Before public void setUp() { ${cursor} }
${:import (org.junit.After)} @After public void tearDown() { ${cursor} }