Eclipse CodeTemplate

利用codeTemplate实现快速编写,输入key再按Alt+/

[color=blue][size=medium][b]1.eclipse自带[/b][/size][/color]
输出 sysout,syserr,systrace
main main
变量 new,cast

还有很多,发现好用的持续添加

[color=blue][size=medium][b]2.自定义[/b][/size][/color]

${: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}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值