´Ù¸¥ ¾ð¾îó·³ SSJSµµ FileÀ» ´Ù·ê ¼ö ÀÖ´Â ±â´ÉÀÌÀÖ´Ù. ±×°É ¹è¿öº¸ÀÚ. ´Ü, ¾Õ¿¡¼µµ °è¼Ó¾ê±âÇÏÁö¸¸,
ÀÌ ÆÄÀÏ Çڵ鸵µµ µ¿½Ã¿¡ ¿©·¯ »ç¿ëÀÚ°¡ ¼öÇàÇϱ⠶§¹®¿¡ LOCK°ú °°Àº ±â´ÉÀ» »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ´Ù.
ÇÁ·ÎÁ§Æ® ´ÜÀ§ÀÇ ÆÄÀÏ °ü¸®°¡ ÇÊ¿äÇϸé, project.lock(), project.unlock()À» ÅëÇØ¼ ºÎ¼öÈ¿°ú¸¦ »ç¿ëÇÏ¸é µÈ´Ù.
- File °´Ã¼
FileÀ» ´Ù·ê ¼ö ÀÖµµ·Ï FileÀ̶ó´Â °´Ã¼¸¦ Áö¿øÇϸç, ´ÙÀ½°ú °°ÀÌ »ý¼ºÇÑ´Ù.
txtfile = new File("\path\file.txt");
- Open / Close
ÀϹÝÀûÀÎ C¾ð¾î¿¡¼Ã³·³, ÆÄÀÏÀ» ¿°í, ´Ý´Â ±â´ÉÀÌ ÀÖÀ¸¸ç, ÇØ´ç ÆÄÀÏ¿¡ ¾²°Å³ª, Àоî¿À´Â ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù.
txtfile.open("r"); // Àбâ¸ðµå·Î ÆÄÀÏÀ» ¿¬´Ù.
txtfile.close();
* °³¹æ ¸ðµå : C¾ð¾î¿Í ¶È°°´Ù.
r | Read Mode |
w | Write Mode |
a | Append Write Mode |
r+, w+, a+ | Read And Write Mode |
- Read / Write
read | ¹®ÀÚ Read |
readln | ÁÙ´ÜÀ§ ¹®ÀÚ¿ Read |
readByte | ¹ÙÀÌÆ®´ÜÀ§ ¹®ÀÚ¿ Read |
write | ¹®ÀÚ Write |
writeln | ÁÙ´ÜÀ§ ¹®ÀÚ¿ Write |
writeByte | ¹ÙÀÌÆ®´ÜÀ§ ¹®ÀÚ¿ Write |
flush | º¯°æ³»¿ë Áï½Ã ¹Ý¿µ |
- ±âŸ ÇÔ¼ö
eof() | ÆÄÀÏÀÇ ³¡¿¡ µµ´ÞÇϸé true¸¦ ¸®ÅÏ |
getLength() | ÆÄÀÏÀÌ byte¼ö. ½ÇÆÐ½Ã -1¸®ÅÏ |
exists() | ÆÄÀÏÀÌ Á¸ÀçÇϸé true |
error() | ¿¡·¯°¡ ¾øÀ¸¸é 0¸®ÅÏ |
´ÙÀ½Àº ÆÄÀÏÀÇ ³»¿ëÀ» ÀÐ¾î¼ Ãâ·ÂÇÏ´Â ¿¹ÀÌ´Ù.
x = new File("\tmp\names.txt");
fileIsOpen = x.open("r");
if( fileOpen ) {
write("file name : " + x + "<BR>");
while( !x.eof() ){
line = x.readln();
if( ! x.eof() )
wiret(line + "<br>");
}
if( x.error() != 0 )
write("error reading file <br>");
x.close();
}else{
write("file open Error");
}
|
- Last Update : 2001.7.5 by Deadfire(http://www.deadfire.net)
|
|
|