myeclipse 设置代码自动提醒功能
设置eclipse/myEclipse代码提示可以方便开发者,不用在记住拉杂的单词,只用打出首字母,就会出现提示菜单。如同dreamweaver一样方便。
设置超级自动提示:
1.菜单window->Preferences->Java->Editor->Content Assist-右边-auto-activaction栏下-Enable auto activation 选项要打上勾
2.Auto Activation triggers for java 后面 直接写入(新版eclipse可以直接写入长字符)“.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,([{”
3.设置反映时间,Auto activation delay 默认为200,一般设置为20~50 4.*此时设置完还没有达到超级提示,软件对类和接口还有很好的提示。
4.继续设置window->Preferences->Java->Editor->Content Assist展开->Advanced 上面的选项卡Select the proposal kinds contained in the 'default' content assist list: 中把7个选项全部勾上!此时设置结束,无论是语句,类,接口,关键字,还是方法,都能自动提示。
激活码生成器
public class GenerateRatings {
public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException {
File out = new File("c:/1.txt");
File docIds = new File("c:/movies.xml");
Writer writer = new FileWriter(out);
writer.write("#The ratings, format is: user id, movie id, preference value\n");
InputSource is = new InputSource(new FileInputStream(docIds));
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
SAXParser sp = factory.newSAXParser();
Random random = new Random(0);//try the same seed for now
DefaultHandler handler = new DocIdContentHandler(writer, random);
//write out the randomly generated ratings
sp.parse(is, handler);
writer.flush();
writer.close();
}
static class DocIdContentHandler extends DefaultHandler {
private boolean inDocId;
private StringBuilder builder = new StringBuilder();
private Writer writer;
private Random random;
DocIdContentHandler(Writer writer, Random random) {
this.writer = writer;
this.random = random;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("str") && attributes.getValue("name") != null && attributes.getValue("name").equals("docid")){
inDocId = true;
}
}
@Override
public void characters(char[] chars, int offset, int len) throws SAXException {
if (inDocId == true){
builder.append(chars, offset, len);
}
}
@Override
public void endElement(String uri, String local, String qName) throws SAXException {
if (inDocId == true){
try {
String itemId = builder.toString();
//Randomly rate the item for some random number of users
Set<String> seenUsers = new HashSet<String>();
int numUsers = random.nextInt(100);
for (int i = 0; i < numUsers; i++){
//Pick a user out of the 990 available
String userId = String.valueOf(random.nextInt(990));
if (seenUsers.contains(userId) == false) {
seenUsers.add(userId);
writer.write(userId);
writer.write(',');
writer.write(itemId);
writer.write(',');
float pref = random.nextFloat() * 5;
int p=Math.round(pref);
writer.write(String.valueOf(p));
writer.write('\n');
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
builder.setLength(0);
inDocId = false;
}
}
}