Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

²»Ã÷°×µÄÒ»µÀJavaÌ⣡

Java code:
import java.io.IOException;
import java.io.File;
import java.io.RandomAccessFile;
class RandomFileTest
{
public static void main(String[] args) throws Exception
{
Student s1=new Student(1, "zhangsan", 90.5);
Student s2=new Student(2, "lisi", 98.5);
Student s3=new Student(3, "wangwu", 96.5);

File userDir=new File(System.getProperties().getProperty("user.dir"));
File tempFile=File.createTempFile("~student", ".tmp", userDir);
tempFile.deleteOnExit();

RandomAccessFile raf=new RandomAccessFile(tempFile, "rw");
s1.write(raf);
s2.write(raf);
s3.write(raf);
raf.seek(0);
Student s=new Student();
for(long i=0;i<raf.length();i=raf.getFilePointer())
{
s.read(raf);
System.out.println("[lenth:"+raf.length()+",i="+i+"] " + s);
}
raf.close();
Thread.sleep(5000);
}
}

class Student
{
int num;
String name;
double score;
public Student()
{
}
public Student(int num, String name, double score)
{
this.num=num;
this.name=name;
this.score=score;
}
public void write(RandomAccessFile raf) throws IOException
{
raf.writeInt(num);
raf.writeUTF(name);
raf.writeDouble(score);
}
public void read(RandomAccessFile raf) throws IOException
{
num=raf.readInt();
name=raf.readUTF();
score=raf.readDouble();
}
public String toString


Ïà¹ØÎÊ´ð£º

jspÒ³Ãæ»ñÈ¡sessionµÄÎÊÌâ - Java / Java EE

ÎÒÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ã滹¿ÉÒÔÈ¡³öÖµÀ´.
µ«ÊÇһˢÐÂ,»òÕß´ò¿ªÐµÄÒ³Ãæ¾ÍÈ¡²»³öÖµÀ´ÁË.
Ææ¹ÖµÄÊÇ,ÎÒ²âÊÔÁíÒ»¸ö³ÌÐòʱºò
ÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ãæ¿ÉÒÔÈ¡³öÖµÀ´,ˢлò´ò¿ªÐÂÒ³ÃæÖµÄÜÈ¡³öÀ´ÁË.
......

Unable to compile class for JSP - Java / Web ¿ª·¢

<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......

ÕÐÆ¸Java web¿ª·¢ÈËÔ±

²àÖØÓÚ»¥ÁªÍø¿ª·¢

JAVA¿ª·¢¹¤³Ìʦ
ְλÃèÊö£º
1¡¢°´USECASE½øÐÐÒµÎñÐèÇó·ÖÎöºÍÈí¼þ¸ÅÒªÉè¼Æ£»
2¡¢½øÐÐÈí¼þÏêϸÉè¼ÆºÍ±àÂëʵÏÖ£¬È·±£ÐÔÄÜ¡¢ÖÊÁ¿ºÍ°²È«£»
3¡¢Î¬»¤ºÍÉý¼¶ÏÖÓÐÈí¼þ²úÆ·£¬¿ìËÙ¶¨Î»² ......

Java RandomAccessFile дÈëtxtÎļþ - Java / Java SE

ÓÃRandomAccessFileдÈëTXTÎļþ²é¿´Ê±ÊÇÂÒÂ룬ÇëÎÊÓÐʲô·½·¨¿ÉÒÔд³É¿É¶ÁµÄÎļþ£¬²»ÊÇÓÃÆäËûµÄÎļþ²Ù×÷£¬¾ÍÊÇÖ»ÓÃRandomAccessFileµÄ·½·¨ÊÇ·ñ¿ÉÒÔʵÏÖ£¿
Java code:
import java.io.*;
public class RandomAcce ......

ÕÐÆ¸È«Ö°¡¢¼æÖ°JAVA¿ª·¢¹¤³Ì



´ó¼ÒºÃ£¬ÎÒÃǽüÆÚÕÐÆ¸È«Ö°¡¢¼æÖ°¿ª·¢¹¤³Ìʦ£¬È«Ö°¹¤³Ìʦ¹¤×÷µØµãÖ÷ÒªÊÇÉîÛÚ£¬¼æÖ°¹¤³Ìʦ±¾ÈË¿ÉÔÚÉîÛÚ£¬Ò²¿ÉÒÔÔÚÒìµØÍ¨¹ýÔ¶³ÌЭͬ¿ª·¢µÄ·½Ê½¿ªÕ¹¹¤×÷£¬ºÏ×÷·½Ê½¿É¹²Í¬É̶¨¡£


ְλE601£ºJava ¹¤³ÌÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ