java ÎļþµÄ¶Áд,×·¼Ó
дÈë¶Á³ö
String num = request.getParameter("num");
String sessionId = request.getParameter("s") + ";" + num + "\n";
File writefile;
try{
String path = "tt.txt";
writefile = new File(path);
if (writefile.exists() == false) {
writefile.createNewFile();
writefile = new File(path); // ÖØÐÂʵÀý»¯
}
FileOutputStream fos = new FileOutputStream(writefile);
out.println("###content:" + sessionId);
fos.write(sessionId.getBytes());
fos.flush();
fos.close();
byte[] b = new byte[17*1024];
FileInputStream fis = new FileInputStream(writefile);
fis.read(b);
String s = new String(b);
out.println(s);
fis.close();
}catch(Exception ex){
System.out.println(ex.getMessage());
}
×·¼Ó:
String path=request.getRealPath(".");
RandomAccessFile rf=new RandomAccessFile("WriteData.txt","rw");//¶¨ÒåÒ»¸öÀàRandomAccessFileµÄ¶ÔÏ󣬲¢ÊµÀý»¯
rf.seek(rf.length());//½«Ö¸ÕëÒÆ¶¯µ½Îļþĩβ
rf.writeBytes("\nAppend a line to the file!");
rf.close();//¹Ø±ÕÎļþÁ÷
out.println("дÈëÎļþÄÚÈÝΪ£º£¼br>");
FileReader fr=new FileReader(path + "\\WriteData.txt");
BufferedReader br=new BufferedReader(fr);//¶ÁÈ¡ÎļþµÄBufferedRead¶ÔÏó
String Line=br.readLine();
while(Line!=null){
out.println(Line + "£¼br>");
Line=br.readLine();
}
fr.close();//¹Ø±ÕÎļþ
Ïà¹ØÎĵµ£º
ÀàÐÍת»»×ܽ᣺
1.ÔÐÍÊý¾Ýbyte,short,int,long,float,double,char,boolean,СÀàÐÍÊý¾Ý¿ÉÒÔÖ±½Ó¸³¸ø´óÀàÐÍÊý¾ÝÀýÈç
int a=1;byte b=2;short c=3;float d=3;double e=4;char f='a';boolean g=true;long l=10;
c=b;
a=f;
d=a;
e=d;
byteÐÍÊý¾Ý²»ÄÜÖ±½Ó¸³¸øcharÐÍÊý¾Ý£¬ÒòΪbyte±íʾµÄÊÇ8λÓзûºÅÊý£¬¶øchar±íʾµ ......
//µ÷Óô洢¹ý³Ì´ø²Î
CallableStatement ca = conn.prepareCall("{call Login (?,?)}");
ca.setString(1,username);
& ......
ʹÓà Java communications API ʵÏÖ²¢Ðж˿ڴòÓ¡
ÕâÊÇÒ»¸öÔÚ¿Í»§Ö§³ÖÖÐÓöµ½µÄÐÂÎÊÌ⣬ÎÒÔÚÏà¹ØµÄÍøÕ¾([url]www.rxtx.org[/url] and [url]www.sun.com.cn[/url])ÉÏÕÒµ½ÁËһЩÓÐÓõÄÐÅÏ¢£¬×îºóÖÕÓÚÔÚWindows XP ºÍ LinuxIA32 ƽ̨ÏÂʵÏÖ²¢Ðж˿ڴòÓ¡ÕâÒ»¹¦ÄÜ¡£
Ê×ÏÈ£¬ÎÒÃÇÒª´ÓSUNµÄÍøÕ¾ÏÂÔØJava communicat ......
¡¶javaÓïÑÔ³ÌÐòÉè¼Æ£¨Ò»£©¡·2009Äê×Ôѧ¿¼ÊÔ´ó¸ÙµÚ1ÕÂ
www.wesiedu.com 2009-5-5 ÔÚÏßÄ£Ä⿼³¡
¶þ¡¢¿Î³ÌÄÚÈÝÓ뿼ºËÄ¿±ê
µÚ1Õ JavaÓïÑÔ»ù´¡
(Ò»)¿Î³ÌÄÚÈÝ
1.1 JavaÓïÑÔµÄÌØµã
1.2 JavaÓ¦ÓóÌÐòºÍСӦÓóÌÐò
1.3 Java³ÌÐòµÄ¿ª·¢¹ý³Ì
1.4±êʶ·ûºÍ¹Ø¼ü×Ö
l.5»ù±¾Êý¾ÝÀàÐÍ
1.5.1 Âß¼ÀàÐÍ
1 ......
µÚ9Õ ÊäÈëºÍÊä³öÁ÷
(Ò»)¿Î³ÌÄÚÈÝ
9.1×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷
9.1.1 File¶ÔÏó
9.1.2Á÷¶ÔÏó
9.2»º³åʽÊäÈëÊä³ö
9.2.1»º³åʽÊäÈë
9.2.2»º³åʽÊä³ö
9.3Ëæ»ú·ÃÎÊ
9.4Îļþ¶Ô»°¿ò
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉÜJava³ÌÐòÊý¾ÝÎļþµÄÊäÈëÊä³ö¼¼Êõ¡£ÒªÇóÄܱàд¼òµ¥µÄJavaÎļþ´¦Àí³ÌÐò¡£
(Èý)¿¼ºË֪ʶµãÓ뿼ºËÒªÇó
1.´´½¨File¶ÔÏó£ ......