java - Clear folder - delete files in folder - J2ME -
i trying clear files in folder using j2me. how do that?
since using j2me, java.io.file
class not available you.
so assuming using fileconnector optional package (fcop).
take @ javadocs javax.microedition.io.file.fileconnection, , should able figure out details.
i'm not j2me expert, think code this:
fileconnection fconn = (fileconnection) connector.open("file:///somedirectory"); enumeration en = fconn.list(); while (en.hasmoreelements()) { string name = en.nextelement(); fileconnection tmp = (fileconnection) connector.open( "file:///somedirectory/" + name); tmp.delete(); tmp.close(); }
exception handling, proper resource handling (using finally
) left exercise reader :-)
Comments
Post a Comment