destdir全称是 destination dir,目标目录,比如编译时的输出目录,复制时的目标目录
一、Ant工具
Ant是一种基于Java的build工具。理论上来说,它有些类似于(Unix)C中的make ,但没有make的缺陷。目前的最新版本为:Ant 1.9.4
当一个代码项目大了以后,每次重新编译,打包,测试等都会变得非常复杂而且重复,因此c语言中有make脚本来帮助这些工作的批量完成。在Java 中应用是平台无关性的,当然不会用平台相关的make脚本来完成这些批处理任务了,ANT本身就是这样一个流程脚本引擎,用于自动化调用程序完成项目的编译,打包,测试等。除了基于JAVA是平台无关的外,脚本的格式是基于XML的,比make脚本来说还要好维护一些。
二、Ant的使用:
1、下载安装
1)下载网址:http://ant.apache.org
2)设置环境变量:
ANT_HOME:ant的安装目录
JAVA_HOME:jdk的安装目录
PATH:把%ANT_HOME%\bin目录加到path变量,以便于从命令行下直接运行ant
2、工程文件目录结构
C:\workspace\ant.test:工程主目录
\src :源程序目录
\build\classes :编译后的 class 文件目录
\lib :开发工程所需要的类库目录,比如开发数据库时所需要的 jdbc lib(这次没用到)
\jar :打包好的 jar 程序目录(这次没用到)
\build.xml :工程配置文件
\build.propertiees:工程资源文件
3、建立工程描述文件和建立工程资源文件build.xml
<?xml version="1.0"?><project default="main" basedir=".">
<echo message="pulling in property files" />
<property file="build.properties" />
<target name="init">
<echo message="init. delete the old class files. and create the new folds." />
<delete dir="${classpath}" />
<mkdir dir="${classpath}" />
</target>
<target name="compile" depends="init">
<echo message="compile the java source files." />
<javac srcdir="src\hello\ant" destdir="${classpath}" />
</target>
<target name="main" depends="compile">
<echo message="calling java to run this java project." />
<java classname="hello.ant.HelloAnt">
<classpath>
<pathelement path="${classpath}" />
</classpath>
</java>
</target>
</project>
4、建立java源文件:hello.ant.HelloAnt.java
package hello.antpublic class HelloAnt {
public static void main(String[] args) {
System.out.println("hello ant, the first time using ant... it is great.")
}
}
5、编译
C:\workspace\ant.test>ant -buildfile build.xmlBuildfile: build.xml
[echo] pulling in property files
init:
[echo] init. delete the old class files. and create the new folds.
[delete] Deleting directory C:\workspace\ant.test\build\classes
[mkdir] Created dir: C:\workspace\ant.test\build\classes
compile:
[echo] compile the java source files.
[javac] Compiling 1 source file to C:\workspace\ant.test\build\classes
main:
[echo] calling java to run this java project.
[java] hello ant, the first time using ant... it is great.
BUILD SUCCESSFUL
Total time: 890 milliseconds
C:\workspace\ant.test>
运行之前确保已经连上 8.8.9.127的共享。import os
import os.path
from os.path import isfile, isdir, join
from shutil import copy
remote_dir = r'\\8.8.9.127\mal\decrpyt'
dest_dir = r'd:\\copied_files'
if not isdir(dest_dir):
os.makedirs(dest_dir)
for f in os.listdir(remote_dir):
if f.lower().endswith('.txt'):
f_path = join(remote_dir, f)
if isfile(f_path):
print 'copying %s...' % f_path
copy(f_path, dest_dir)
用fgets函数读取文件中某行的数据,某列数据就必须读入每行的第几个字符,再存入到一个字符串当里。
例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<stdio.h>
#include<string.h>
voidmain()
{
chara[100],b[100],c[100]
inti=3,j=4,k=0//第三行,第四列
FILE*fp=fopen("data.txt","r")
while(fgets(c,100,fp)){//读入每行数据
i--
if(i==0)strcpy(a,c)//读到第三行数据
b[k++]=c[j-1]//把每行的那列字符拷到b中
}
b[k]=0
printf("第%d行数据:%s\n",i,a)
printf("第%d列数据:%s\n",j,b)
fclose(fp)
扩展资料
R语言的使用
read.csv/csv2:逗号分隔数据读取
.csv可能是目前最常见的平面文件类型了。它代表的是comma-separatedvalues,简单来讲就是,文件里每一个单独的数据值都是用逗号进行分隔的。
数据文件被读取到R工作环境中的第一步通常为调用str函数来对该数据对象进行初步检视,下面的代码列出了该函数最简单的使用方式。
>str(object=flights)
'data.frame':6obs.of6variables:
$carrier:Factorw/4levels"AA","B6","DL",..:441234
$flight:int1545171411417254611696
$tailnum:Factorw/6levels"N14228","N24211",..:124653
$origin:Factorw/3levels"EWR","JFK","LGA":132231
$dest:Factorw/5levels"ATL","BQN","IAH",..:334215
$air_time:int227227160183116150