´«ÖDz¥¿Íjavaѧϰ 3g¿ª·¢Android2
½ñÌìÊÇѧϰAndroid¿ª·¢µÄµÚ¶þÌ죺
½ñÌìÖ÷ҪѧϰÁËÎļþµÄ¶ÁÈ¡¡¢ÒÔ¼°¶ÔxmlÎļþµÄ½âÎö£º
ʹÓÃÎļþ½øÐÐÊý¾Ý´æ´¢£º
ActivityÌṩÁËopenFileOutput()·½·¨¿ÉÒÔÓÃÓÚ°ÑÊý¾ÝÊä³öµ½ÎļþÖУ¬¾ßÌåµÄʵÏÖ¹ý³ÌÓëÔÚJ2SE»·¾³Öб£´æÊý¾Ýµ½ÎļþÖÐÊÇÒ»ÑùµÄ¡£
public class FileActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
...
FileOutputStream outStream = this.openFileOutput("itcast.txt",
Context.MODE_PRIVATE);
outStream.write("´«ÖDz¥¿Í".getBytes());
outStream.close();
}
}
openFileOutput()·½·¨µÄµÚÒ»²ÎÊýÓÃÓÚÖ¸¶¨ÎļþÃû³Æ£¬²»ÄÜ°üº¬Â·¾¶·Ö¸ô·û“/” £¬Èç¹ûÎļþ²»´æÔÚ£¬Android
»á×Ô¶¯´´½¨Ëü¡£´´½¨µÄÎļþ±£´æÔÚ/data/data/<package
name>/filesĿ¼£¬È磺
/data/data/cn.itcast.action/files/itcast.txt
£¬Í¨¹ýµã»÷Eclipse²Ëµ¥“Window”-“Show
View”-“Other”£¬ÔÚ¶Ô»°´°¿ÚÖÐÕ¹¿ªandroidÎļþ¼Ð£¬Ñ¡ÔñÏÂÃæµÄFile ExplorerÊÓͼ£¬È»ºóÔÚFile
ExplorerÊÓͼÖÐÕ¹¿ª/data/data/<package
name>/filesĿ¼¾Í¿ÉÒÔ¿´µ½¸ÃÎļþ¡£
openFileOutput()·½·¨µÄµÚ¶þ²ÎÊýÓÃÓÚÖ¸¶¨²Ù×÷ģʽ£¬ÓÐËÄÖÖģʽ£¬·Ö±ðΪ£º
Context.MODE_PRIVATE
= 0
Context.MODE_APPEND
= 32768
Context.MODE_WORLD_READABLE = 1
Context.MODE_WORLD_WRITEABLE = 2
Context.MODE_PRIVATE
£º
ΪĬÈϲÙ×÷ģʽ£¬´ú±í¸ÃÎļþÊÇ˽ÓÐÊý¾Ý£¬Ö»Äܱ»Ó¦Óñ¾Éí·ÃÎÊ£¬ÔÚ¸ÃģʽÏ£¬Ð´ÈëµÄÄÚÈݻḲ¸ÇÔÎļþµÄÄÚÈÝ£¬Èç¹ûÏë°ÑÐÂдÈëµÄÄÚÈÝ×·¼Óµ½ÔÎļþÖС£¿ÉÒÔʹÓÃContext.MODE_APPEND
Context.MODE_APPEND
£º
ģʽ»á¼ì²éÎļþÊÇ·ñ´æÔÚ£¬´æÔÚ¾ÍÍùÎļþ×·¼ÓÄÚÈÝ£¬·ñÔò¾Í´´½¨ÐÂÎļþ¡£
Context.MODE_WORLD_READABLEºÍContext.MODE_WORLD_WRITEABLEÓÃÀ´¿ØÖÆÆäËûÓ¦ÓÃÊÇ·ñÓÐȨÏÞ¶Áд¸ÃÎļþ¡£
MODE_WORLD_READABLE
£º±íʾµ±Ç°Îļþ¿ÉÒÔ±»ÆäËûÓ¦ÓöÁÈ¡£»MODE_WORLD_WRITEABLE
£º±íʾµ±Ç°Îļþ¿ÉÒÔ±»Æ
Ïà¹ØÎĵµ£º
Ö»Õë¶Ô²»Õý³£µÄÌõ¼þ²ÅʹÓÃÒì³£
Òì³£Ö»Ó¦¸Ã±»ÓÃÓÚ²»Õý³£µÄÌõ¼þ£¬ËüÃÇÓÀÔ¶²»Ó¦±»ÓÃÓÚÕý³£µÄ¿ØÖÆÁ÷¡£
ÏÂÃæÊÇÒ»¸öÓÃÒì³£×÷±éÀú½áÊøÌõ¼þµÄÀÄÓÃÒì³£µÄÀý×Ó£º
//horrible abuse of exceptions. Don't ever do this!
try{
int i=0;
while(true)a[i++].f();
}catch(ArrayIndexOutOfBoundsException e){
......
¶ÔÓÚÕâ¸öϵÁÐÀïµÄÎÊÌ⣬ÿ¸öѧJavaµÄÈ˶¼Ó¦¸Ã¸ã¶®¡£µ±È»£¬Èç¹ûÖ»ÊÇѧJavaÍæÍæ¾ÍÎÞËùνÁË¡£Èç¹ûÄãÈÏΪ×Ô¼ºÒѾ³¬Ô½³õѧÕßÁË£¬È´²»ºÜ¶®ÕâЩÎÊÌ⣬Ç뽫Äã×Ô¼ºÖعé³õѧÕßÐÐÁС£ÄÚÈݾùÀ´×ÔÓÚCSDNµÄ¾µäÀÏÌù¡£
ÎÊÌâÒ»£ºÎÒÉùÃ÷ÁËʲô£¡
String s = "Hello world!";
¡¡Ðí¶àÈ˶¼×ö¹ýÕâÑùµÄÊÂÇ飬µ«ÊÇ£¬ÎÒÃǵ½µ×ÉùÃ÷ÁËʲô£¿»Ø´ðͨ ......
¡¡¡¡ÕâÀïËù˵µ½µÄJavaÖеÄÅÅÐò²¢²»ÊÇÖ¸²åÈëÅÅÐò¡¢Ï£¶ûÅÅÐò¡¢¹é²¢ÅÅÐòµÈ¾ßÌåµÄÅÅÐòËã·¨¡£¶øÊÇÖ¸Ö´ÐÐÕâЩÅÅÐòË㷨ʱ£¬±È½ÏÁ½¸ö¶ÔÏó“´óС”µÄ±È½Ï²Ù×÷¡£ÎÒÃǺÜÈÝÒ×Àí½âÕûÐ굀 i>j ÕâÑùµÄ±È½Ï·½Ê½£¬µ«µ±ÎÒÃǶԶà¸ö¶ÔÏó½øÐÐÅÅÐòʱ£¬ÈçºÎ±È½ÏÁ½¸ö¶ÔÏóµÄ“´óС”ÄØ£¿ÕâÑùµÄ±È½Ï stu1 > stu2 ÏÔÈ»ÊDz»¿É ......
½ñÌì¼ÌÐøÙ¡ÀÏʦµÄ½ÌÓý°ì¹«ÏµÍ³µÄÂọ́º
1. Ô±¹¤Â¼ÈëµÄ·þÎñÆ÷¶ËµÄ¼òµ¥ÑéÖ¤:
1). ʹÓà struts µÄ validator ¿ò¼Ü
2). ÑéÖ¤¹æÔòͬä¯ÀÀÆ÷¶ËµÄ jQuery µÄ validator ÑéÖ¤.
3). ÒÔ email ×Ö¶ÎΪÀý, ÑéÖ¤ ......