阿翔编程学-Java文件操作

阿翔编程学-webservice过滤器 过滤器类package baseinfo.com.windtec.offline.server.baseinfo;import java.io.IOException;import java.util.ArrayList;import java.util.List;import java.util.StringTokenizer;import javax.servlet.Filte 阅读详情

package com.ocuf.oais.common;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import org.xml.sax.SAXException;

import com.ocuf.oais.module.FileModule;

/**
 * 文件操作
 *
 * @author CaoXiang
 *
 */
public class FileCommon {
 List<String> list = new ArrayList<String>();

 private static List<String> APPLIST = new ArrayList<String>();

 private static List Mylist = new ArrayList<String>();
 
 private String realPath = this.getClass().getClassLoader().getResource("/").getPath();
 
 public static void main(String[] args) {
  FileCommon f = new FileCommon();
  try {
   //System.out.println(realPath);
   //f.showXml("Archive-Shrink-test.xml");
   f.readFolderByFilePath("E:/workspace/oaisWeb/src/com/ocuf/oais/metadata/file/fileread");
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
 
 public String xmlDebugForMessage(String filename) throws ParserConfigurationException, SAXException, IOException {
  StringBuffer buffer = new StringBuffer();
  String file = "中国国家税务总局.xml";
  System.out.println(realPath);
   DocumentBuilderFactory factory = DocumentBuilderFactory
     .newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();
   FileInputStream stream = new FileInputStream(
     realPath+"com//ocuf//oais//metadata//file//filetemp//"+ filename);
   Document document = builder.parse(stream);
   // 获得根节点
   Node root = document.getFirstChild();
   if (root.getTextContent() != null) {
    // System.out.println(root.getTextContent()+" ddd");
    // 获得所有子节点
    NodeList nodeList = root.getChildNodes();
    for(int i=0;i<nodeList.getLength();i++) {
     Node book = nodeList.item(i);
     String title2 = book.getNodeName();
     if(title2.equals("信息总体")) {
      NodeList b2 = nodeList.item(i).getChildNodes();
      for(int ii=0;ii<b2.getLength();ii++) {
       Node book2 = b2.item(ii);
       String title3 = book2.getNodeName();
       if(title3.equals("保护描述信息")) {
        NodeList b3 = b2.item(ii).getChildNodes();
        for(int iii=0;iii<b2.getLength();iii++) {
         Node book3 = b3.item(iii);
         String title4 = book3.getNodeName();
         if(title4.equals("参考信息")) {
          NodeList b4 = b3.item(iii).getChildNodes();
          for(int iiii=0;iiii<b2.getLength();iiii++) {
           Node book4 = b4.item(iiii);
           String title5 = book4.getNodeName();
           if(title5.equals("标识信息")) {
            NodeList list = book4.getChildNodes();
            for(int listsize=0; listsize<list.getLength(); listsize++) {
             buffer.append(list.item(listsize).getTextContent().trim()+",");
            }
           }
          }
         }
        }
       }
      }
     }
    }
    // 关闭流
    stream.close();
   }
   //System.out.println(buffer.toString().substring(1, buffer.toString().length()));
   return buffer.toString().substring(1, buffer.toString().length());
 }

 /**
  * 文件的写入
  *
  * @param filePath(文件路径)
  * @param fileName(文件名)
  * @param args[]
  * @throws IOException
  */

 public void writeFile(String filePath, String fileName, String[] args)
   throws IOException {
  FileWriter fw = new FileWriter(filePath + fileName);
  PrintWriter out = new PrintWriter(fw);
  for (int i = 0; i < args.length; i++) {
   out.write(args[i]);
   out.println();
   out.flush();
  }
  fw.close();
  out.close();
 }

 /**
  *
  * 文件的写入
  *
  * @param filePath(文件路径)
  *
  * @param fileName(文件名)
  *
  * @param args
  *
  * @throws IOException
  *
  */

 public void writeFile(String filePath, String fileName, String args)
   throws IOException

 {

  FileWriter fw = new FileWriter(filePath + fileName);

  fw.write(args);

  fw.close();

 }

 /**
  *
  * 创建与删除文件
  *
  * @param filePath
  *
  * @param fileName
  *
  * @return 创建成功返回true
  *
  * @throws IOException
  *
  */

 public boolean createAndDeleteFile(String filePath, String fileName)
   throws IOException

 {

  boolean result = false;

  File file = new File(filePath, fileName);

  if (file.exists())

  {

   file.delete();

   result = true;

   System.out.println("文件已经删除!");

  }

  else

  {

   file.createNewFile();

   result = true;

   System.out.println("文件已经创建!");

  }

  return result;

 }

 /**
  *
  * 创建和删除目录
  *
  * @param folderName
  *
  * @param filePath
  *
  * @return 删除成功返回true
  *
  */

 public boolean createAndDeleteFolder(String folderName, String filePath)

 {

  boolean result = false;

  try

  {

   File file = new File(filePath + folderName);

   if (file.exists())

   {

    file.delete();

    System.out.println("目录已经存在,已删除!");

    result = true;

   }

   else

   {

    file.mkdir();

    System.out.println("目录不存在,已经建立!");

    result = true;

   }

  }

  catch (Exception ex)

  {

   result = false;

   System.out.println("CreateAndDeleteFolder is error:" + ex);

  }

  return result;

 }

 /**
  *
  * 输出目录中的所有文件及目录名字
  *
  * @param filePath
  *
  */
 public List readFolderByFilePath(String filePath) {
  //System.out.println(realPath);
  this.Mylist.clear();
  File file = new File(filePath);
  File[] tempFile = file.listFiles();
  List backList = new ArrayList();
  //System.out.println(tempFile.length);
  for (int i = 0; i < tempFile.length; i++) {
   if (tempFile[i].isFile()) {
    // System.out.println("File : "+tempFile[i].getName());
   }
   if (tempFile[i].isDirectory()) {
    File file2 = new File(filePath+"/"+tempFile[i].getName());
    //System.out.println("Directory : "+tempFile[i].getName());
    File[] tempFile2 = file2.listFiles();
    for (int j = 0; j < tempFile2.length; j++) {
    if(tempFile2[j].isDirectory()) {
     //System.out.println("Directory : "+tempFile2 [j].getName());
     try {
      //System.out.println(filePath+"/" + tempFile[i].getName() + "/" + tempFile2 [j].getName());
      this.Mylist = this.getFolderByFilePath2(filePath+"/" + tempFile[i].getName() + "/" + tempFile2 [j].getName());
      backList.addAll(this.Mylist);
     } catch (Exception e) {
      e.printStackTrace();
     }
    }
    }
   }
  }
  return backList;
 }

 /*
  * (non-Javadoc)
  *
  * @see com.jxsafe.source.common.conf.ISaxReader#getChildNodes(org.w3c.dom.NodeList)
  */
 public List getChildNodes(NodeList childNode) {
  // System.out.println(childNode.getLength());
  for (int i = 0; i < childNode.getLength(); i++) {
   Node obj = (Node) childNode.item(i);
   // System.out.println(obj.getFirstChild().getNodeName());
   // 当该节点没有属性时
   if (!obj.getNodeName().substring(0, 1).equals("#")) {
    // System.out.println(obj.getParentNode().getNodeName());
    if (obj.hasChildNodes()) {
     String title = obj.getFirstChild().getTextContent().trim();
     if (title.equals("") || title == null) {
     } else {
      if (obj.getParentNode().getNodeName().equals("头信息")) {
       // System.out.println(list+" ddd");
       list.add(title);
      } else {
      }
     }
    }
    // 获得该节点的子节点 递归所有的节点
    NodeList childNodes = obj.getChildNodes();
    if (childNodes.getLength() > 0) {
     getChildNodes(childNodes);
    }
   }
  }
  return list;
 }

 /*
  * (non-Javadoc)
  *
  * @see com.jxsafe.source.common.conf.ISaxReader#getChildNodes(org.w3c.dom.NodeList)
  */
 public List getChildNodes2(NodeList childNode) {
  List<String> list = new ArrayList<String>();
  for (int i = 0; i < childNode.getLength(); i++) {
   Node obj = (Node) childNode.item(i);
   // 获得该节点的子节点 递归所有的节点
   NodeList childNodes = obj.getChildNodes();
   if (childNodes.getLength() > 0) {
    for (int j = 0; j < childNodes.getLength(); j++) {
     Node book = childNodes.item(i);
     String title2 = book.getFirstChild().getNodeValue();
     // System.out.println(title2);
     list.add(title2);
    }
   }
  }
  // System.out.println(list);
  return list;
 }

 /*
  * (non-Javadoc)
  *
  * @see com.jxsafe.source.common.conf.ISaxReader#showXml()
  */
 public List showXml(String file) throws Exception {
  list.clear();
  if (file != null) {
   DocumentBuilderFactory factory = DocumentBuilderFactory
     .newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();
   FileInputStream stream = new FileInputStream(
     realPath+"com//ocuf//oais//metadata//file//filetemp//"
       + file);
   // InputStream stream =
   // this.getClass().getResourceAsStream("E://workspace//oaisWeb//src//com//ocuf//oais//metadata//file//filetemp//"+file);
   // InputStream schemaStr =
   // this.getClass().getResourceAsStream("SubmitInfoPackage.xsd");
   Document document = builder.parse(stream);
   // 获得根节点
   Node root = document.getFirstChild();
   if (root.getTextContent() != null) {
    // System.out.println(root.getTextContent()+" ddd");
    // 获得所有子节点
    NodeList nodeList = root.getChildNodes();
    List v = this.getChildNodes(nodeList);
    // 关闭流
    stream.close();
    // ValidatXML valitate = new ValidatXML();
    // valitate.run(file);
    return v;
   } else {
    return null;
   }
  }
  return new ArrayList();
 }
 
 /*
  * (non-Javadoc)
  *
  * @see com.jxsafe.source.common.conf.ISaxReader#showXml()
  */
 public List showXml2(String filepath, String file) throws Exception {
  list.clear();
  if (file != null) {
   DocumentBuilderFactory factory = DocumentBuilderFactory
     .newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();
   FileInputStream stream = new FileInputStream(
     filepath + "/"
       + file);
   // InputStream stream =
   // this.getClass().getResourceAsStream("E://workspace//oaisWeb//src//com//ocuf//oais//metadata//file//filetemp//"+file);
   // InputStream schemaStr =
   // this.getClass().getResourceAsStream("SubmitInfoPackage.xsd");
   Document document = builder.parse(stream);
   // 获得根节点
   Node root = document.getFirstChild();
   if (root.getTextContent() != null) {
    // System.out.println(root.getTextContent()+" ddd");
    // 获得所有子节点
    NodeList nodeList = root.getChildNodes();
    List v = this.getChildNodes(nodeList);
    // 关闭流
    stream.close();
    // ValidatXML valitate = new ValidatXML();
    // valitate.run(file);
    return v;
   } else {
    return null;
   }
  }
  return new ArrayList();
 }
 
 /**
  * 获得文件
  *
  * @param filePath
  * @throws Exception
  */
 public List getFolderByFilePath2(String filePath) throws Exception {
  List<FileModule> list = new ArrayList<FileModule>();
  File file = new File(filePath);
  File[] tempFile = file.listFiles();
  for (int i = 0; i < tempFile.length; i++) {
   if (tempFile[i].isFile()) {
    FileModule fileModule = new FileModule();
    // System.out.println(tempFile[i].getName());
    List v = this.showXml2(filePath,tempFile[i].getName());
    // System.out.println(v);
    // System.out.println(tempFile[i].getName()+v.size());
    // 设置相关参数值
    if (v != null) {
     String fname = tempFile[i].getName().substring(0,
       tempFile[i].getName().indexOf("."));
     fileModule.setFileid(String.valueOf(i));
     fileModule.setFilename(fname);
     fileModule.setFilepath(tempFile[i].getPath());
     //取出需要的数据用/分开
     //System.out.println(tempFile[i].getPath());
     //String[] splitArr = tempFile[i].getPath().split("//");
     //System.out.println(tempFile[i].getPath().indexOf("fileread"));
     //System.out.println(tempFile[i].getPath().substring(tempFile[i].getPath().indexOf("fileread")+9, tempFile[i].getPath().length()));
     String newStr = tempFile[i].getPath().substring(tempFile[i].getPath().indexOf("fileread")+9, tempFile[i].getPath().length()).trim().toString();
     int firstIndex = newStr.indexOf("//");
     int lastIndex = newStr.lastIndexOf("//");
     String firstStr = newStr.substring(0, firstIndex);
     String secondStr = newStr.substring(firstIndex+1, lastIndex);
     String totalStr = firstStr+",,,"+secondStr;
     fileModule.setRealpath(totalStr);
     //System.out.println(firstStr+" d " +secondStr);
     // 单位名称
     // String s = v.get(0).toString();
     // System.out.println(s);
     fileModule.setCompanyaddress((String) v.get(0));
     // 单位URI标识
     fileModule.setUri((String) v.get(1));
     // 登陆密码
     fileModule.setPassword((String) v.get(2));
     // 版本号
     fileModule.setVersion((String) v.get(3));
     // 递交时间
     fileModule.setDatetime((String) v.get(4));
     // 紧急程度
     fileModule.setLeavel((String) v.get(5));
     // 类型
     fileModule.setType((String) v.get(6));
     // 密级
     fileModule.setWordcorp((String) v.get(7));
     // IP
     fileModule.setIp((String) v.get(8));
     // 电子签章
     fileModule.setCardnumber((String) v.get(9));
     list.add(fileModule);
    }

   }
  }
  return list;
 }

 /**
  * 获得文件
  *
  * @param filePath
  * @throws Exception
  */
 public List getFolderByFilePath(String filePath) throws Exception {
  List<FileModule> list = new ArrayList<FileModule>();
  File file = new File(filePath);
  File[] tempFile = file.listFiles();
  for (int i = 0; i < tempFile.length; i++) {
   if (tempFile[i].isFile()) {
    FileModule fileModule = new FileModule();
    // System.out.println(tempFile[i].getName());
    List v = this.showXml(tempFile[i].getName());
    // System.out.println(v);
    // System.out.println(tempFile[i].getName()+v.size());
    // 设置相关参数值
    if (v != null) {
     String fname = tempFile[i].getName().substring(0,
       tempFile[i].getName().indexOf("."));
     fileModule.setFileid(String.valueOf(i));
     fileModule.setFilename(fname);
     fileModule.setFilepath(tempFile[i].getPath());
     // 单位名称
     // String s = v.get(0).toString();
     // System.out.println(s);
     fileModule.setCompanyaddress((String) v.get(0));
     // 单位URI标识
     fileModule.setUri((String) v.get(1));
     // 登陆密码
     fileModule.setPassword((String) v.get(2));
     // 版本号
     fileModule.setVersion((String) v.get(3));
     // 递交时间
     fileModule.setDatetime((String) v.get(4));
     // 紧急程度
     fileModule.setLeavel((String) v.get(5));
     // 类型
     fileModule.setType((String) v.get(6));
     // 密级
     fileModule.setWordcorp((String) v.get(7));
     // IP
     fileModule.setIp((String) v.get(8));
     // 电子签章
     fileModule.setCardnumber((String) v.get(9));
     list.add(fileModule);
    }

   }
  }
  return list;
 }
 
 public File[] sortFiles(String filepath) {
  TreeMap   tm=new   TreeMap();  
        File   f=new   File(filepath);  
        File   subFile[]=f.listFiles(); 
        File[] fileArr = new File[subFile.length];
        int   fileNum=subFile.length;  
        for(int   i=0;i<fileNum;i++)  
            {  
                Long   tempLong=new   Long(subFile[i].lastModified());  
                tm.put(tempLong,subFile[i]);  
            }  
      Set   set=tm.keySet();  
      Iterator   iter=set.iterator();  
      int i=0;
      while(iter.hasNext())  
      {  
        Object   key=iter.next();  
        Object   objValue=tm.get(key);  
        File   tempFile=(File)objValue;  
        System.out.println(tempFile.getPath()+"/t"+key.toString()); 
        fileArr[i]=tempFile;
        i++;
      }    
      return fileArr;
 }

 /**
  * 判断文件夹中是否存在文件,没有文件返回错误页
  */
 public boolean countFolderByFilePath(String filePath) {
  File file = new File(filePath);
  File[] tempFile = file.listFiles();
  if (tempFile.length > 0) {
   return true;
  } else {
   return false;
  }
 }

 /**
  *
  * 检查文件中是否为一个空
  *
  * @param filePath
  *
  * @param fileName
  *
  * @return 为空返回true
  *
  * @throws IOException
  *
  */

 public boolean fileIsNull(String filePath, String fileName)
   throws IOException

 {

  boolean result = false;

  FileReader fr = new FileReader(filePath + fileName);

  if (fr.read() == -1)

  {

   result = true;

   System.out.println(fileName + " 文件中没有数据!");

  }

  else

  {

   System.out.println(fileName + " 文件中有数据!");

  }

  fr.close();

  return result;

 }

 /**
  *
  * 读取文件中的所有内容
  *
  * @param filePath
  *
  * @param fileName
  *
  * @throws IOException
  *
  */

 public void readAllFile(String filePath, String fileName)
   throws IOException

 {

  FileReader fr = new FileReader(filePath + fileName);

  int count = fr.read();

  while (count != -1)

  {

   System.out.print((char) count);

   count = fr.read();

   if (count == 13)

   {

    fr.skip(1);

   }

  }

  fr.close();

 }

 /**
  *
  * 一行一行的读取文件中的数据
  *
  * @param filePath
  *
  * @param fileName
  *
  * @throws IOException
  *
  */

 public void readLineFile(String filePath, String fileName)
   throws IOException

 {

  FileReader fr = new FileReader(filePath + fileName);

  BufferedReader br = new BufferedReader(fr);

  String line = br.readLine();

  while (line != null)

  {

   System.out.println(line);

   line = br.readLine();

  }

  br.close();

  fr.close();

 }
 
 /**
  * 字符编码转换
  * @param param
  * @return
  */
 public static String UTF82GB2312(String param)
   {
     try
     {
         new String(param.getBytes("ISO8859-1"), "UTF-8");
         return new String(param.getBytes("ISO8859-1"), "GBK");
     }
     catch(Exception e)
     {
         return null;
     }
   }
 
 /**
  * 字符编码转换
  * @param buf
  * @return
  */
 private static String UTF82GB2312(byte buf[])
   {
     int len = buf.length;
     StringBuffer sb = new StringBuffer(len/2);
     for(int i =0; i<len;i++)
     {
         if(by2int(buf[i])<=0x7F) sb.append((char)buf[i]);
         else if(by2int(buf[i])<=0xDF && by2int(buf[i])>=0xC0)
         {
           int bh = by2int(buf[i] & 0x1F);
           int bl = by2int(buf[++i] & 0x3F);
           bl = by2int(bh << 6 | bl);
           bh = by2int(bh >> 2);
           int c = bh<<8 | bl;
           sb.append((char)c);
         } else if(by2int(buf[i])<=0xEF && by2int(buf[i])>=0xE0){
           int bh = by2int(buf[i] & 0x0F);
           int bl = by2int(buf[++i] & 0x3F);
           int bll = by2int(buf[++i] & 0x3F);
           bh = by2int(bh << 4 | bl>>2);
           bl = by2int(bl << 6 | bll);
           int c = bh<<8 | bl;
     //空格转换为半角
     if(c==58865){
         c = 32;
     }
           sb.append((char)c);
         }
     }
     return sb.toString();
   }

 /**
  * 字符编码转换
  * @param b
  * @return
  */
 private static int by2int(int b)
   {
     return b & 0xff;
   }

}
 

信息奥赛课课通(C++)p154-1近似排序 试题描述 读入一对正整数,将这两个数之间(包括这两个数本身)的所有数按下述特别规则排序后输出,该特别规则是按两数倒过来的值进行比较决定其大小,如30倒过来为3,29倒过来为92,则29大于30. 输入要求 1行,包含两个用空格隔开的自然数,这两个自然数给出了待排序数的范围,其中1≤第一个数≤第二个数≤999999999,两个数之差不超过100. 输出要求 输出排序后的数据,每行输出... 阅读详情

相关推荐

别再死记硬背了!用Python可视化带你直观理解柯西收敛定理(附NumPy代码)

本文通过Python可视化技术,结合NumPy和Matplotlib,直观展示柯西收敛定理的动态过程。文章提供了完整的代码实现,帮助读者从抽象数学定义过渡到具象理解,特别适合数学学习者和Python开发者。通过热力图和交互式参数探索,读者可以清晰观察数列收敛特性,提升数学分析的学习效率。

weixin_28465009的博客 191

“文件下载”案例的几个bug

一、路径获取失败,弹出错误500(解决时间最长的) 定义Servlet,错误代码如下: @WebServlet("/downloadServlet") public class DownLoadServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Piely_oni的博客 291

腾讯股票接口API(1)——根据股票代码获取详情

获取股票简要信息,找来找去也没有找到官方的文档,都是复制粘贴的,这里先简单记录一下。 1.简要信息 以贵州茅台为例: http://qt.gtimg.cn/q=s_sh600519 // sh600519是贵州茅台的股票代码,根据自己的关键字拼接URL 可以直接在Android项目中请求,会得到如下一串字符串: v_s_sh600519="1~贵州茅台~600519~2075.95~42.95~2.11~38930~794942~~26078.04~GP-A"; 这里v_s代表简要信息,sh600519

GeofferySun的专栏 6万+

阿翔编程学-Axis

 Axis篇Axis简介Axis是Apache组织推出的SOAP引擎,Axis项目是Apache组织著名的SOAP项目的后继项目,目前最新版本是采用Java开发的1.1版本,C++的版本正在开发之中。Axis v1.1软件包可以从http://ws.apache.org/axis/dist/1_1/下载得到。但是Axis不仅仅是一个SOAP引擎,它还包括:    1)、 一个独立运行的

曹翔 1593

基于APDL语言的结构优化设计

同理,二次微分值称为二阶值。通俗地讲优化分析,指的找到一种方案可以满足所有的设计要求,而且所需的支出(如重量,面积,体积,应力,费用等)最小。设计方案的任何方面都是可以优化的,比如说:尺寸(如厚度),形状(如过渡圆角的大小),支撑位置,制造费用,自然频率,材料特性等。完成分析文件的建立后,就可以进行优化分析了,如果在交互方式下进行优化的话,最好先在ANSYS数据库中用分析文件建立参数,其优点有:初始参数可以作为一阶分析方法的起点,且对于优化过程参数在数据库中可以在GUI下进行操作,便于定义优化变量。

m0_73816777的博客 1181

UE4 Instanced Mesh 半透明渲染顺序不对解决

以绿色方块为Instanced Mesh为例。 正确的半透应该是这样的: 这是一般蓝图Actor方块,其半透是正常的。 然而Instanced Mesh因为过多,UE4不给你缓存正确的渲染顺序。所以,在不改代码的情况下,想解决Instanced Mesh半透问题,是不可能的。不正确的半透如下: 注意到错误发生在Instanced Mesh的方块与方块之间。 但我就是要解决,...

qq_41524721的博客 5573

阿翔编程学-Java XML文件的验证

package com.ocuf.oais.common;import java.io.FileInputStream;import java.util.ArrayList;import java.util.List;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.io.SAXR

曹翔 1485

AD9361数字调制入门:从IQ调制原理到动手实现第一个ASK信号(Vivado工程详解)

本文详细介绍了如何使用AD9361射频收发器实现ASK数字调制,从IQ调制原理到Vivado工程实现。通过Verilog代码示例和FPGA架构设计,帮助开发者理解纯逻辑实现数字调制解调的关键技术,特别适合软件无线电(SDR)初学者入门实践。

weixin_29158047的博客 378

阿翔编程学-Axis日志服务类

阿翔编程学-Axis日志服务类//===========================================================//日志服务类程序 author:曹翔//===========================================================package com.ruix.service;import java.i

曹翔 1160

AI自瞄原理剖析(四)从Yolo推理坐标到屏幕坐标:基于FOV视角与焦距的坐标变换与精准瞄准

从Yolo推理框架得到的坐标到屏幕坐标的转换是一个涉及到FOV视角、焦距以及分辨率的复杂过程。通过数学公式,我们可以将推理框坐标反推为游戏内的实际坐标,并最终映射到屏幕坐标系中。利用这些信息,AI自瞄系统能够精确计算出准星从当前位置移动到敌人位置的距离,实现精准的自动瞄准。通过这种方法,AI自瞄系统能够在不同的游戏环境下灵活应对,提供高度精确的操作体验。在AI自瞄系统中,目标检测仅仅是第一步,获取到预测框的坐标后,我们还需要将这些坐标转换为实际屏幕上的精确位置。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1342

数字信号处理(一):Xilinx Vivado DDS IP核设计实例(文末附源码)

前言 在数字信号处理时我们经常会用到数字变频,包数字下变频(DDC)和数字上变频(DUC),这其中会用到Xilinx公司的DDS IP核或者Altera公司的NCO IP核来产生本振频率,以现数字域信号频谱搬移。本文我们通过例化Xilinx公司的DDS IP核来产生混频器本振输入频率,并给出Modelsim仿真测试结果。 1、Xilinx DDS IP简介 Xilinx公司的DDS IP核使用AX...

FPGA_Designer 1万+

阿翔编程学-Lucene的例子

package src.com;import java.io.BufferedReader;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.Reader;import java.io.StringRe

曹翔 941

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

阿翔编程学-Lucene入门与使用

Lucene入门与使用        本文主要面向具体使用,适用于已熟悉java编程的lucene初学者。1. Lucene的简介1.1 Lucene 历史      org.apache.lucene包是纯java语言的全文索引检索工具包。      Lucene的作者是资深的全文索引/检索专家,最开始发布在他本人的主页上,2001年10月贡献给APACHE,成为APACHE基金ja

曹翔 6750

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

阿翔编程学-JMail邮件接收类

package com.jxsafe.source.common.applications.source.classinfo.jmail;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileInputStream;import java.io.Fil

曹翔 1551

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

阿翔编程学-HttpClient

package ocuf.action.upload;import java.io.File;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.co

曹翔 740

阿翔编程学-Java Servlet验证码的输出

package com.jxsafe.source.common.applications.source.classinfo.random;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import com.jxsafe.source.common.app

曹翔 718

阿翔编程学-WebSphere下开发WebService服务

(一)首先先新建一个Web Project左边选择Web,右边选种动态Web项目,单击下一步输入Web Project Name就行了,最后点击完成。(二)新建一个简单的Java Bean类点击完成,接下来修改该JavaBean的文件内容,加入如下代码:/**  * 用户登陆判断的方法  * @param username   *        用户名  * @pa

曹翔 1790

阿翔编程学-操作Excel文件的类

package com.jxsafe.source.common.applications.source.classinfo.random;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.ByteArrayOutputStream;import java.io.File;

曹翔 2195

阿翔编程学-DES

package ocuf.action.upload;import java.io.File;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.co

曹翔 869

阿翔编程学-Java杂文

Java基础:类,对象,注释,数据类型,成员变量,成员函数,运算符,控制语句,继承,多态,父类,子类,方法重载,方法覆盖,访问控制,包,静态变量,静态方法,抽象类,接口,线程。    J2EE开发: 输入流,输出流,TCP/IP操作,JDBC,SERVLET,集合框架,JSP    Struts:ACTION,FORMBEAN,STRUTS-CONFIG.XML,LOG,VALIDATOR   

曹翔 953

阿翔编程学-Castor

代码如下:package com.windtec.offline.server.service.gongan;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;impor

曹翔 1398

阿翔编程学-Axis传递Pojo对象

Axis传递Pojo对象(1)编写服务器端Java程序 //===========================================================//传递Java对象的服务类程序 author:曹翔//===========================================================package com.ruix.s

曹翔 1688

阿翔编程学-struts2.0简单的例子

    今天在apache网站上无意中看到了struts项目2.0.1正式发布了,怀着欣喜的心情我下载了stuts2.0.1完整包。 Struts2.0.1是struts项目和WebWork2.2项目的合并版本,集成了两大流行MVC框架的优点,对struts框架来说是一个大的提升,同时也更大程度地简化了开发人员的开发过程。我简单地研究了一下这个新版本,现在给大家介绍一个入门级的小例子,希望能对学习

曹翔 1464

阿翔编程学-Java缓存类的实现

package com.jxsafe.source.common.applications.source.classinfo.collection;import java.util.LinkedList;import com.jxsafe.source.common.applications.source.classinfo.collection.imp.IReLinkedList;/

曹翔 2194

阿翔编程学-XFire

 XFire篇XFire简介    它拥有一个轻量级的信息处理模块,通过STAX来与SOAP信息相结合。提供了一个工作在web services下的简单API,支持POJO和schema开发。XFire是 CodeHaus 推出的下一代的 Java SOAP框架,它构建了 POJO 和 SOA 之间的桥梁,主要特性就是支持将 POJO 通过非常简单的方式发布成 Web 服务,这种处理方

曹翔 1073

阿翔编程学-HTTP文件下载

 import java.io.RandomAccessFile;import java.io.File;import java.io.InputStream;import java.io.DataInputStream;import java.io.BufferedInputStream;import java.io.FileInputStream;import java.net.HttpU

曹翔 1020
上一篇: 阿翔编程学-JMail邮件接收类
下一篇: 阿翔编程学-Java XML文件的验证
java_xiang
博客等级 码龄20年 14粉丝 42原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址