IT猫扑网文章教程

分类分类

Oracle删除指定目录文件

2015-06-28 00:00作者:网管联盟

  由于微软的图表控件Chart生成的临时图片保存在C:TempImageFiles,所以需要进行定时删除。操作步骤如下。

  Sys用户登录

  execute dbms_java.grant_permission('TXGS','SYS:java.io.FilePermission','C:TempImageFiles','read');

  execute dbms_java.grant_permission('TXGS','SYS:java.io.FilePermission','C:TempImageFiles*','delete,read');

  Java源:

  create or replace and compile java source named deletefile as

  import java.awt1.*;

  import java.io.*;

  import java.io.File;

  import java.lang.String;

  public class DELETEFILE

  {

  public static String delAllFile()

  {

  String   path=&C:\TempImageFiles&;

  File file = new File(path);

  if (!file.exists()) {return &&; }

  if (!file.isDirectory()) {return &&; }

  String[] tempList = file.list();

  File temp = null;

  for (int i = 0; i < tempList.length; i++)

  {

  if (path.endsWith(File.separator))

  {

  temp = new File(path + tempList[i]);

  }

  else

  {

  temp = new File(path + File.separator + tempList[i]);

  }

  if (temp.isFile())

  {

  temp.delete();

  }

  if (temp.isDirectory())

  {

  java.io.File myDelFile = new java.io.File(path+&\&+ tempList[i]);

  myDelFile.delete();

  }

  }

  return( &0 &);

  }

  }

  存储过程:

  create or replace procedure RunDx as language java name   'DELETEFILE.delAllFile()';

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消