directory.exists,中如何判断一个文件是否存在?
1.引用 System.IO。
2.string dirpath =...//具体自己添。
3.string Filepath=...//具体自己添。
4.if (Directory.Exists(path))//判断目录是否存在。
5.if(File.Exist(filepath))//如果是文件的话。
C盘是指电脑硬盘主分区之一,一般用于储存或安装系统使用。针对安装在本地硬盘的单操作系统来说,是默认的本地系统启动硬盘。大部分C盘内文件主要由Documents and Settings、Windows、Program Files等系统文件夹组成,Program Files文件夹一般都是安装软件的默认位置,但是也是病毒的位置,所以要对C盘进行严密保护。
C盘对于本地硬盘的单操作系统来说,是极其重要的,所以平时存放数据尽量不要放C盘。默认在C盘需要移动出来的个人目录是:C:\Documents and Settings\你的登录帐号\ Documents。
ug60显示directory?
你这个应该是环境变量中“UGII_BASE_DIR”变量值有问题,你的变量应该是D,这个变量就是UG的安装路径,比如我的是E:\Program Files (x86)\Siemens\NX 8.0忘采用
新手如何学习Java?
首先要了解Java基础,数据库,前端,Java web,框架等都是需要有一定的掌握的。如果有项目经验,找工作会更好。当然,如果有更深层次的分布式架构、服务器虚拟化技术、企业开发解决方法等知识,能更好的找到工作哦!
如果你想学习,下面这套2020年Java中高级程序员学习线路图能帮到你!(含所需要学习的技术及配套视频)一、Java基础JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。
在Java基础板块中有6个子模块的学习:
基础语法,可帮助你建立基本的编程逻辑思维;面向对象,以对象方式去编写优美的Java程序;集合,后期开发中存储数据必备技术;IO,对磁盘文件进行读取和写入基础操作;多线程与并发,提高程序效率;异常,编写代码逻辑更加健全;网络编程,应用服务器学习基础,完成数据的远程传输。学习该阶段,可以完成一些简单的管理系统、坦克大战游戏、QQ通信等。配套学习视频:
Java教程|Java基础班-小白的福音(冯老师)
二、数据库数据库不仅仅是Java开发工程师的必学课程,也是其他语言都需要掌握的技能。用于对交互过程中客户的数据进行存储。
该板块包括关系型数据库和非关系型数据库。
例如:MySQL、oracle、redis、MongoDB等。数据库学习完毕后,可以将数据存储到数据库中,也可以通过SQL语句从数据库中查询数据,结合Java项目可以实现动态站点的数据的保存。
技术树
配套学习视频:
5天玩转MySQL
Sharding-JDBC从入门到精通
java进阶教程4天oracle快速入门
三、前端技术Javaweb阶段包括前端、数据库和动态网页。Javaweb是互联网项目的入门课程,是学习后面高进阶课程的基础。
首先,我们先看一下前端板块。该板块主要包括如下几个模块:
HTML5,网页制作标记语言;CSS,对HTML制作网页进行美化;JavaScript,嵌入在页面中的脚本语言,具备逻辑性;Vue,前端框架,简化了与服务器端交互的操作,用户良好的交互体验是必不可少的。学习前端技术后,可以完成类似京东、淘宝的前端工程的编写。
技术树
配套学习视频:
Ajax从入门到精通|黑马程序员
2018年Vue.js深入浅出教程
PHP HTML+CSS+JavaScript教程
零基础玩转微信小程序
四、动态网页技术动态网页是中级程序员服务器端编程的基础,是高级框架学习的必备课程,后期学习的框架、服务底层都是基于动态网页技术之上的。
该板块包括Javaweb核心技术、包括Servlet、Request、Response、Cookie和Session等,通过这些技术的学习可以完成动态站点开发,可更好的完成服务器端与客户的交互,让页面的数据“动”起来,做出小型的应用系统。
技术树
配套学习视频:
JavaWeb教程_JavaWeb入门教程|黑马程序员
servlet4.0新特性
五、编程强化编程强化是对解决实际问题方面做一个深入的了解和应用,是对JavaSE基础的加强,对后期自动以框架和对一些服务框架的底层理解做支撑。
编程强化板块主要包括如下几个模块:多线程高级、涉及线程内存、线程通信等;JVM优化,对JVM底层进行调优来提高项目执行效率;NIO,同步非阻塞IO来提高效率。
学习该阶段,可以对原有项目进行优化从而使程序更快更稳定。
技术树
配套学习视频:
Java多线程与并发库高级应用
java程序算法与实际运用--刘意老师
匠心之作java基础强化之JVM内存结构
匠心之作java基础强化之强转溢出&浮点数运算精讲
六、软件项目管理JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。
在Java基础板块中有6个子模块的学习:基础语法,可帮助你建立基本的编程逻辑思维;面向对象,以对象方式去编写优美的Java程序;集合,后期开发中存储数据必备技术;IO,对磁盘文件进行读取和写入基础操作;多线程与并发,提高程序效率;异常,编写代码逻辑更加健全;网络编程,应用服务器学习基础,完成数据的远程传输。
学习该阶段,可以完成一些简单的管理系统、坦克大战游戏、QQ通信等。
技术树
配套学习视频:
Maven教程_Maven视频教程|黑马程序员
Git零基础入门到实战详解
七、热门技术框架使用Javaweb进行企业级开发是完全可以的,但是开发效率比较低,所以对常用的逻辑操作进行封装就形成了框架,因此框架是企业开发的入门技能。
热门框架板块主流框架有如下几个:Spring框架,占据统治地位,其生态系统涉及各个方面解决方案;MyBatis框架,使用ORM思想对数据库进行操作。
该板块学习后,就可以进行真实企业级项目开发了,做出的项目也会更加符合企业要求。
技术树
配套学习视频:
Java教程|Springmvc由浅入深教程
java进阶教程Mybatis由浅入深教程
JPA教程_JPA视频教程|黑马程序员
数据层全栈方案 SpringData 高级应用
八、分布式架构方案随着互联网的发展,业务的复杂性和用户的体验性都需要提高,所以分布式架构出现了。该板块主要讲解的是分布式架构的相关解决方案。
主要包括如下模块:Dubbo,高性能的 RPC 服务发布和调用框架;SpringBoot,简化Spring应用的初始搭建以及开发过程;Spring Cloud,一系列框架的有序集合,如服务发现注册、配置中心、负载均衡、断路器、数据监控等。
该板块的学习,可以具备大型互联网项目开发的必备技术和实际经验,为进入BATJ打下基础
技术树
配套学习视频:
java中级程序员教程快速入门Zookeeper+dubbo
两小时由浅入深搞定springboot
4天从浅入深精通SpringCloud 微服务架构
九、服务器中间件中间件板块是大型互联网项目中必备的。服务中间件可以帮助各子模块间实现互相访问,消息共享或统一访问等功能。其包括远程服务框架中间件,例如阿里(Apache)的RPC框架Dubbo等;消息队列中间件,例如:阿里巴巴开源分布式中间件RocketMQ、高吞吐量消息发布和流处理服务Kafka等。
学习服务中间件是中级JavaEE工程师必要技术,也是JavaEE架构师必须精通的技术。
技术树
配套学习视频:
MongoDB基础入门到高级进阶
REDIS高级应用:使用redis消息队列完成秒杀过期订单处理
十、服务器技术不管是使用原生Javaweb进行开发,还是使用框架进行开发,项目最终需要对外发布才能供全世界的人访问到,而服务器板块就可以解决这个问题,所以服务器是项目发布的必要技术。该板块包括虚拟化和web应用服务器的学习,主要包括如下几个模块:Vmware,虚拟机软件;Linux,专门用于服务器的系统;Nginx,集群部署时反向代理服务器;Tomcat,项目发布时主要使用的服务器。
该板块学习后,我们就可以把开发好的项目发布到服务器中,然后供你的小伙伴远程访问了,超酷!
技术树
配套学习视频:
高可用的并发解决方案nginx+keepalived
Linux运维189讲系统教程
服务器tomcat(Java开发必会)
利刃出鞘-Tomcat核心原理解析
十一、容器技术容器化技术是近两年超级火的一个专题,通过容器化技术可以对环境进行打包,方便移植,大大提高了开发效率。该板块包括容器化技术Docker和其平台管理引擎Kubernetes,其中,Docker 是一个开源的应用容器引擎,可以打包应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的Linux或Windows 机器上,也可以实现虚拟化。而Kubernetes是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效。通过该板块的学习,你可以通过上述技术快速搭建环境,节省开发时间,提高开发效率。
技术树
配套学习视频:
深入解析docker容器化技术
十二、业务解决方案虽然我们已经具备了基础技术和高阶技术,但是要想与企业开发相接轨,还需要对实际项目的业务解决方案进行探究。而此版块就是在实际业务场景中的真实解决方案集合,常用的业务解决方案有如下:搜索业务场景解决方案、日志收集与分析场景解决方案、工作流引擎场景解决方案、任务调度场景解决方案、地图开发平台场景解决方案、支付开放平台场景解决方案、图表可视化场景解决方案。通过分析实际业务来学习这个解决方案技术集,完全可以达到中级甚至高级工程师水平。
技术树
好了,学习线路图分享到这里, 如果有最新学习视频,我会继续更新!
mahout面试题?
之前看了Mahout官方示例 20news 的调用实现;于是想根据示例的流程实现其他例子。网上看到了一个关于天气适不适合打羽毛球的例子。
训练数据:
Day Outlook Temperature Humidity Wind PlayTennis
D1 Sunny Hot High Weak No
D2 Sunny Hot High Strong No
D3 Overcast Hot High Weak Yes
D4 Rain Mild High Weak Yes
D5 Rain Cool Normal Weak Yes
D6 Rain Cool Normal Strong No
D7 Overcast Cool Normal Strong Yes
D8 Sunny Mild High Weak No
D9 Sunny Cool Normal Weak Yes
D10 Rain Mild Normal Weak Yes
D11 Sunny Mild Normal Strong Yes
D12 Overcast Mild High Strong Yes
D13 Overcast Hot Normal Weak Yes
D14 Rain Mild High Strong No
检测数据:
sunny,hot,high,weak
结果:
Yes=》 0.007039
No=》 0.027418
于是使用Java代码调用Mahout的工具类实现分类。
基本思想:
1. 构造分类数据。
2. 使用Mahout工具类进行训练,得到训练模型。
3。将要检测数据转换成vector数据。
4. 分类器对vector数据进行分类。
接下来贴下我的代码实现=》
1. 构造分类数据:
在hdfs主要创建一个文件夹路径 /zhoujainfeng/playtennis/input 并将分类文件夹 no 和 yes 的数据传到hdfs上面。
数据文件格式,如D1文件内容: Sunny Hot High Weak
2. 使用Mahout工具类进行训练,得到训练模型。
3。将要检测数据转换成vector数据。
4. 分类器对vector数据进行分类。
这三步,代码我就一次全贴出来;主要是两个类 PlayTennis1 和 BayesCheckData = =》
package myTesting.bayes;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.util.ToolRunner;
import org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob;
import org.apache.mahout.text.SequenceFilesFromDirectory;
import org.apache.mahout.vectorizer.SparseVectorsFromSequenceFiles;
public class PlayTennis1 {
private static final String WORK_DIR = "hdfs://192.168.9.72:9000/zhoujianfeng/playtennis";
/*
* 测试代码
*/
public static void main(String[] args) {
//将训练数据转换成 vector数据
makeTrainVector();
//产生训练模型
makeModel(false);
//测试检测数据
BayesCheckData.printResult();
}
public static void makeCheckVector(){
//将测试数据转换成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"testinput";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean参数是,是否递归删除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失败!");
System.exit(1);
}
//将序列化文件转换成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean参数是,是否递归删除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件转换成向量失败!");
System.out.println(2);
}
}
public static void makeTrainVector(){
//将测试数据转换成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"input";
String output = WORK_DIR+Path.SEPARATOR+"tennis-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean参数是,是否递归删除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失败!");
System.exit(1);
}
//将序列化文件转换成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean参数是,是否递归删除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件转换成向量失败!");
System.out.println(2);
}
}
public static void makeModel(boolean completelyNB){
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-vectors"+Path.SEPARATOR+"tfidf-vectors";
String model = WORK_DIR+Path.SEPARATOR+"model";
String labelindex = WORK_DIR+Path.SEPARATOR+"labelindex";
Path in = new Path(input);
Path out = new Path(model);
Path label = new Path(labelindex);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean参数是,是否递归删除的意思
fs.delete(out, true);
}
if(fs.exists(label)){
//boolean参数是,是否递归删除的意思
fs.delete(label, true);
}
TrainNaiveBayesJob tnbj = new TrainNaiveBayesJob();
String[] params =null;
if(completelyNB){
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow","-c"};
}else{
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow"};
}
ToolRunner.run(tnbj, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("生成训练模型失败!");
System.exit(3);
}
}
}
package myTesting.bayes;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.mahout.classifier.naivebayes.BayesUtils;
import org.apache.mahout.classifier.naivebayes.NaiveBayesModel;
import org.apache.mahout.classifier.naivebayes.StandardNaiveBayesClassifier;
import org.apache.mahout.common.Pair;
import org.apache.mahout.common.iterator.sequencefile.PathType;
import org.apache.mahout.common.iterator.sequencefile.SequenceFileDirIterable;
import org.apache.mahout.math.RandomAccessSparseVector;
import org.apache.mahout.math.Vector;
import org.apache.mahout.math.Vector.Element;
import org.apache.mahout.vectorizer.TFIDF;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.Multiset;
public class BayesCheckData {
private static StandardNaiveBayesClassifier classifier;
private static Map<String, Integer> dictionary;
private static Map<Integer, Long> documentFrequency;
private static Map<Integer, String> labelIndex;
public void init(Configuration conf){
try {
String modelPath = "/zhoujianfeng/playtennis/model";
String dictionaryPath = "/zhoujianfeng/playtennis/tennis-vectors/dictionary.file-0";
String documentFrequencyPath = "/zhoujianfeng/playtennis/tennis-vectors/df-count";
String labelIndexPath = "/zhoujianfeng/playtennis/labelindex";
dictionary = readDictionnary(conf, new Path(dictionaryPath));
documentFrequency = readDocumentFrequency(conf, new Path(documentFrequencyPath));
labelIndex = BayesUtils.readLabelIndex(conf, new Path(labelIndexPath));
NaiveBayesModel model = NaiveBayesModel.materialize(new Path(modelPath), conf);
classifier = new StandardNaiveBayesClassifier(model);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("检测数据构造成vectors初始化时报错。。。。");
System.exit(4);
}
}
/**
* 加载字典文件,Key: TermValue; Value:TermID
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<String, Integer> readDictionnary(Configuration conf, Path dictionnaryDir) {
Map<String, Integer> dictionnary = new HashMap<String, Integer>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
String name = path.getName();
return name.startsWith("dictionary.file");
}
};
for (Pair<Text, IntWritable> pair : new SequenceFileDirIterable<Text, IntWritable>(dictionnaryDir, PathType.LIST, filter, conf)) {
dictionnary.put(pair.getFirst().toString(), pair.getSecond().get());
}
return dictionnary;
}
/**
* 加载df-count目录下TermDoc频率文件,Key: TermID; Value:DocFreq
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<Integer, Long> readDocumentFrequency(Configuration conf, Path documentFrequencyDir) {
Map<Integer, Long> documentFrequency = new HashMap<Integer, Long>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().startsWith("part-r");
}
};
for (Pair<IntWritable, LongWritable> pair : new SequenceFileDirIterable<IntWritable, LongWritable>(documentFrequencyDir, PathType.LIST, filter, conf)) {
documentFrequency.put(pair.getFirst().get(), pair.getSecond().get());
}
return documentFrequency;
}
public static String getCheckResult(){
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String classify = "NaN";
BayesCheckData cdv = new BayesCheckData();
cdv.init(conf);
System.out.println("init done...............");
Vector vector = new RandomAccessSparseVector(10000);
TFIDF tfidf = new TFIDF();
//sunny,hot,high,weak
Multiset<String> words = ConcurrentHashMultiset.create();
words.add("sunny",1);
words.add("hot",1);
words.add("high",1);
words.add("weak",1);
int documentCount = documentFrequency.get(-1).intValue(); // key=-1时表示总文档数
for (Multiset.Entry<String> entry : words.entrySet()) {
String word = entry.getElement();
int count = entry.getCount();
Integer wordId = dictionary.get(word); // 需要从dictionary.file-0文件(tf-vector)下得到wordID,
if (StringUtils.isEmpty(wordId.toString())){
continue;
}
if (documentFrequency.get(wordId) == null){
continue;
}
Long freq = documentFrequency.get(wordId);
double tfIdfValue = tfidf.calculate(count, freq.intValue(), 1, documentCount);
vector.setQuick(wordId, tfIdfValue);
}
// 利用贝叶斯算法开始分类,并提取得分最好的分类label
Vector resultVector = classifier.classifyFull(vector);
double bestScore = -Double.MAX_VALUE;
int bestCategoryId = -1;
for(Element element: resultVector.all()) {
int categoryId = element.index();
double score = element.get();
System.out.println("categoryId:"+categoryId+" score:"+score);
if (score > bestScore) {
bestScore = score;
bestCategoryId = categoryId;
}
}
classify = labelIndex.get(bestCategoryId)+"(categoryId="+bestCategoryId+")";
return classify;
}
public static void printResult(){
System.out.println("检测所属类别是:"+getCheckResult());
}
}
pythondatabaseislocked怎么解决?
-创建数据库createdatabaseifnotexistssopdmcomment‘thisistestdatabase’withdbproperties(‘creator’=’gxw’,’date’=’2014-11-12’
)--数据库键值对属性信息location‘/my/preferred/directory’
;--查看数据库的描述信息和文件目录位置路径信息describedatabasesopdm;--查看数据库的描述信息和文件目录位置路径信息(加上数据库键值对的属性信息)describedatabaseextendedsopdm;
还没有评论,来说两句吧...