java基础

/**
  * 取得asc码
  * @param str
  */
 public void getASC(String str){
  char[] stt = str.toCharArray();
  for(int i = 0 ; i<stt.length ; i++){
   System.out.println(stt[i]+"========"+(int)stt[i]);
  }
 }

 

 

private String generateFileName() {
  // 获得当前时间
  DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
  // 转换为字符串
  String formatDate = format.format(new Date());
  // 随机生成文件编号20100402161050136
  int random = new Random().nextInt(10000);
  return new StringBuffer().append(formatDate).append(random).toString();
 }

 

private void getFileName() throws IOException{
  File directory =new File("D:/danwork/work/CPP"); 
  File file=new File(directory.getCanonicalPath());
  File[] myfile=file.listFiles();
  for (int i=0;i<myfile.length;i++){
   String mydd=myfile[i].toString();
   String myaa=mydd.substring(mydd.length()-4,mydd.length());
   String myss=".doc";
   if(myaa.equals(myss)) {
    System.out.println(mydd);
   }
  }
 }

你可能感兴趣的:(java)