|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
java也能做一些底层语言开发做的事情(难度很高,不是java顶尖高手是做不来的),原创只完成最复杂功效,主动天生setter,getter当bean中属性较多时能够节俭工夫:
Usage:javaJavaBeanMakeraaa.txtbbb
1.aaa.txtisthetextfileinfollowingstyle,youcangetaexample--jeru.txtinattachment
======================
intid
Stringname
intage
======================
2bbbisthefilenameofyourjavabeanwithout.java,soifyouwantaTest.java
justtype"JavaJavaBeanMakeraaa.txtTest"
=================jeru.txt==========================
intid
Stringname
intage
=================JavaBeanMaker.java================
importjava.io.*;
importjava.util.*;
publicclassJavaBeanMaker{
publicstaticvoidmain(String[]args){
System.out.println("Readingdatas......");
try{
//readpropertiesofsourcetextfile
inti=0;
Stringrecord=newString();
Vectorproperty=newVector();
RandomAccessFilesource=newRandomAccessFile(args[0],"r");
while((record=source.readLine())!=null){
i++;
property.addElement(record);
}
source.close();
RandomAccessFiledestine=newRandomAccessFile(args[1],"rw");
Stringcontent="//ThisJavaBeanismakebyJerusJavaBeanMaker"+"
";
content+="publicclass"+args[1]+"{"+"
";
String[]tmp=newString[3];
for(i=0;i<property.size();i++){
Stringstr=(String)property.elementAt(i);
//System.out.println("Value"+i+":"+str);
StringTokenizertokens=newStringTokenizer(str);
for(intj=0;j<=1;j++){
tmp[j]=tokens.nextToken();
System.out.println("token:"+tmp[j]);
}
//capitaltmp[1]
tmp[2]=tmp[1].substring(0,1).toUpperCase()+tmp[1].substring(1);
System.out.println(tmp[2]);
content+=""+tmp[0]+""+tmp[1]+";"+"
";
content+=""+"publicvoidset"+tmp[2]+"("+tmp[1]+"){"+"
";
content+=""+"this."+tmp[1]+"="+tmp[1]+";"+"
";
content+=""+"}"+"
";
content+=""+"public"+tmp[0]+"get"+tmp[2]+"(){"+"
";
content+=""+"return"+tmp[1]+";"+"
";
content+=""+"}"+"
";
}
System.out.println("thelastcontentis"+content);
content+="}";
destine.writeBytes(content);
destine.close();
}catch(Exceptione){e.getMessage();}
}
}
ruby里有这些工具吗?又要简单多少?我没有用过这两门语言,我估计在这些语言力没有很统一的这种标准,或者根本就没有提供。 |
|