Java 文件操作

JSP&EL表达式&MVC&三层结构综合案例 文章目录JSP1,JSP 概述2,JSP 快速入门2.1 搭建环境2.2 导入 JSP 依赖2.3 创建 jsp 页面2.4 编写代码2.5 测试3,JSP 原理4,JSP 脚本4.1 JSP 脚本分类4.2 案例4.2.1 需求4.2.2 实现4.2.3 成品代码4.2.4 测试4.3 JSP 缺点5,EL 表达式5.1 概述5.2 代码演示5.3 域对象6,JSTL标签6.1 概述6.2 if 标签6.3 forEach 标签6.3.1 用法一6.3.2 用法二7 阅读详情
文件操作:

文件的建立/检查与删除

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>文件的建立、检查与删除</title>
</head>
<body>
<%
String path=request.getRealPath("");
//out.println(path);
File f=new File(path,"File.txt");
//out.println(f);
//out.println(f.exists());

if(f.exists()){//检查File.txt是否存在
f.delete();//删除File.txt文件
out.println(path + "/File.txt 存在,已删除。");
}else{
f.createNewFile();//在当前目录下建立一个名为File.txt的文件
out.println(path + "/File.txt 不存在,已建立。");//输出目前所在的目录路径
}
%>



目录的建立/检查与删除

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>目录的建立/检查与删除</title>
</head>
<body>
<%
String path=request.getRealPath("");
path=path + "/Sub";//将要建立的目录路径
File d=new File(path);//建立代表Sub目录的File对象,并得到它的一个引用
if(d.exists()){//检查Sub目录是否存在
d.delete();
out.println("Sub目录存在,已删除");
}else{
d.mkdir();//建立Sub目录
out.println("Sub目录不存在,已建立");
}
%>
</body>
</html>



如何在JSP中处理虚拟目录

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>JSP中如何处理虚拟目录</title>
</head>
<body>
取得虚拟目录对应的磁盘路径<br>
Web站点主目录的位置为<font color=#ff0000><%=request.getRealPath("/")%></font><br>
JSP网页所在的目录位置<font color=#ff0000><%=request.getRealPath("./")%></font><br>
JSP网页所在目录上一层目录的位置<font color=#ff0000><%=request.getRealPath("../")%></font><br>
</body>
</html>



文件属性的取得

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.Date,java.io.*"%>
<html>
<head>
<title>文件属性的取得</title>
</head>
<body>
<%
String path=request.getRealPath("/");
File f=new File(path,"ReadData.txt");
if(f.exists()){
%>
<%=f.getName()%>的属性如下:<br><br>
文件长度为:<%=f.length()%>
<%=f.isFile()?"是文件":"不是文件"%><br>
<%=f.isDirectory()?"是目录":"不是目录"%><br>
<%=f.canRead()?"可读取":"不可读取"%><br>
<%=f.canWrite()?"可写入":"不可写入"%><br>
<%=f.isHidden()?"是隐藏文件":"不是隐藏文件"%><br>
文件的最后修改日期为:<%=new Date(f.lastModified())%><br>
<%
}else{
f.createNewFile();//在当前目录下建立一个名为ReaData.txt的文件
%>
<%=f.getName()%>的属性如下:<br><br>
文件长度为:<%=f.length()%>
<%=f.isFile()?"是文件":"不是文件"%><br>
<%=f.isDirectory()?"是目录":"不是目录"%><br>
<%=f.canRead()?"可读取":"不可读取"%><br>
<%=f.canWrite()?"可写入":"不可写入"%><br>
<%=f.isHidden()?"是隐藏文件":"不是隐藏文件"%><br>
文件的最后修改日期为:<%=new Date(f.lastModified())%><br>
<%
}
%>
</body>
</html>

取出目录中文件的方法

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>取出目录中文件的方法--列出目录中的文件</title>
</head>
<body>
<%
String path=request.getRealPath("/");
File d=new File(path);//建立当前目录中文件的File对象
File list[]=d.listFiles();//取得代表目录中所有文件的File对象数组
out.println("<font color=#ff0000>" + path + "目录下的文件:</font><br>");
for(int i=0;i<list.length;i++){
if(list<I>.isFile()){
out.println(list<I>.getName() + "<br>");
}
}
out.println("<br><font color=#ff0000>" + path + "目录下的目录:</font><br>");
for(int i=0;i<list.length;i++){
if(list<I>.isDirectory()){
out.println(list<I>.getName() + "<br>");
}
}
%>
</body>
</html>



判断是否为空白文件

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>判断是否为空白文件</title>
</head>
<body>
<%
String path=request.getRealPath("/");
out.println(path);
FileReader fr=new FileReader(path + "/AtEnd.txt");//建立FileReader对象,并实例化为fr
//对FileReader类生成的对象使用read()方法,可以从字符流中读取下一个字符。
if(fr.read()==-1)//判断是否已读到文件的结尾
{
out.print("AtEnd.txt文件中没有数据<br>");
}else{
out.println("AtEnd.txt文件中有数据");
}
fr.close();
%>
</body>
</html>
    <B>读取所有的文件数据</B>
<ccid_nobr>
<table width="400" border="1" cellspacing="0" cellpadding="2"
bordercolorlight = "black" bordercolordark = "#FFFFFF" align="center">
<tr>
<td bgcolor="e6e6e6" class="code" style="font-size:9pt">
<pre><ccid_code> <%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*,java.lang.*"%>
<html>
<head>
<title>读取所有的文件数据</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileReader fr=new FileReader(path + "/ReadData.txt");
//关键在于读取过程中,要判断所读取的字符是否已经到了文件的末尾,
并且这个字符是不是文件中的断行符,即判断该字符值是否为13。
int c=fr.read();//从文件中读取一个字符
//判断是否已读到文件结尾
while(c!=-1){
out.print((char)c);//输出读到的数据
c=fr.read();//从文件中继续读取数据
if(c==13){//判断是否为断行字符
out.print("<br>");//输出分行标签
fr.skip(1);//略过一个字符
//c=fr.read();//读取一个字符
}
}
fr.close();
%>
</body>
</html>

一行一行读取数据

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>文件读取</title>
</head>
<body>
<%
String path=request.getRealPath("");//取得当前目录的路径
FileReader fr=new FileReader(path + "/file/inc/t.txt");//建立FileReader对象,并实例化为fr
BufferedReader br=new BufferedReader(fr);//建立BufferedReader对象,并实例化为br
String Line=br.readLine();//从文件读取一行字符串
//判断读取到的字符串是否不为空
while(Line!=null){
out.println(Line + "<br>");//输出从文件中读取的数据
Line=br.readLine();//从文件中继续读取一行数据
}
br.close();//关闭BufferedReader对象
fr.close();//关闭文件
%>
</body>
</html>



略过文件中的字符不读取

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>略过字节不读取</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileReader fr=new FileReader(path + "/ReadData.txt");
fr.skip(2);//跳过2个字节
int c=fr.read();//读取一个字节
while(c!=-1){
out.print((char)c);
c=fr.read();
}
fr.close();
%>
</body>
</html>



将数据写入文件

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将数据写入文件</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileWriter fw=new FileWriter(path + "/WriteData.txt");//建立FileWriter对象,并实例化fw
//将字符串写入文件
fw.write("大家好!");
fw.write("本书是《JSP编程技巧》");
fw.write("请多多指教!");
fw.write("email:stride@sina.com");
fw.close();

FileReader fr=new FileReader(path + "/WriteData.txt");
BufferedReader br=new BufferedReader(fr);//建立BufferedReader对象,并实例化为br
String Line=br.readLine();
//读取一行数据
out.println(Line + "<br>");
br.close();//关闭BufferedReader对象
fr.close();
%>
</body>
</html>



将写入文件的数据分行

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将写入文件的数据分行</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileWriter fw=new FileWriter(path + "/WriteData.txt");
BufferedWriter bw=new BufferedWriter(fw);
bw.write("大家好!");
bw.write("本书是《JSP编程技巧》。");
bw.newLine();//断行
bw.write("请多多指教!");
bw.newLine();//断行
bw.write("email: stride@sina.com");
bw.flush();//将数据更新至文件
fw.close();//关闭文件流
out.println("写入文件内容为:<br>");
FileReader fr=new FileReader(path + "/WriteData.txt");
BufferedReader br=new BufferedReader(fr);
String Line=br.readLine();//读取一行数据
while(Line!=null){
out.println(Line + "<br>");
Line=br.readLine();
}
fr.close();
%>
</body>
</html>



如何将数据追加写入到文件

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将写入文件的数据分行</title>
</head>
<body>
<%
String path=request.getRealPath(".");
RandomAccessFile rf=new RandomAccessFile(path + "/WriteData.txt","rw");
//定义一个类RandomAccessFile的对象,并实例化
rf.seek(rf.length());//将指针移动到文件末尾
rf.writeBytes("/nAppend a line to the file!");
rf.close();//关闭文件流
out.println("写入文件内容为:<br>");
FileReader fr=new FileReader(path + "/WriteData.txt");
BufferedReader br=new BufferedReader(fr);//读取文件的BufferedRead对象
String Line=br.readLine();
while(Line!=null){
out.println(Line + "<br>");
Line=br.readLine();
}
fr.close();//关闭文件
%>
</body>
</html></I></I></I></I>

Java的文件操作 什么是文件?文件这一名词在生活中是比较常见的。比如:在办公场所,我们会使用文件夹来保存我们的资料等一些有用的东西。类似的,在计算机中,文件也是用来保存用户信息的地方。我们办公场所的文件时放到桌子上或者柜子里,同样的计算机的文件也有存放的地方—硬盘。说到硬盘,我有一个问题:请问大家知道内存和硬盘的区别吗?(1)内存的存储空间比较小,硬盘的存储空间比较大(2)内存访问的速度比较快,硬盘访问的速度比较慢(3)内存在电脑电拔掉的情况下,保存在内存的数据会丢失而硬盘是不会丢失数据。... 阅读详情

相关推荐

西门子精致面板TP1200 历史数据(历史数据、审计追踪) 移存到网络路径

TP1200 审计追踪

zhang080602的博客 5768

JSP实用教程实验九文件操作

2. 输入输出流FileInputStream、FileOutputStream、BufferedInputStream、BufferedOutputStream、FileRead、FileWriter、BufferedRead、BufferedWriter,RandomAccessFile类。通过本次实验掌握使用输入流读取服务器端的文件的方法和MVC模式读取文件的方法,4. 掌握file对象使用以及各种流的读写操作,实现文件上传与下载。文件:ch9_1.jsp。3. 文件上传、下载。听学《新概念英语》。

Annzz123的博客 1627

【DAY11】超参数调整专题1

核心优势: 它不是随机选择下一个点,而是根据先前评估的结果建立一个概率模型(通常是高斯过程),预测哪些参数组合可能产生更好的结果,并据此选择下一个评估点。这使得它在寻找最优解方面通常比随机搜索更高效(用更少的迭代次数达到相似或更好的性能),特别是当模型训练(单次评估)非常耗时的时候。实际上,有着非常多的方式可以实现贝叶斯优化,上面的代码比较简洁美观,贝叶斯优化和网格搜索的代码书写风格高度一致。- 需要定义参数的搜索空间,与随机搜索类似,当搜索空间非常大时,它通常比网格搜索和随机搜索更有效。

daomingwu1的博客 747

java文件操作

文件的建立/检查与删除文件的建立、检查与删除String path=request.getRealPath("");//out.println(path);File f=new File(path,"File.txt");//out.println(f);//out.println(f.exists());if(f.exists()){//检查File.txt是否存在 f.delete();/

ken的网络居 1370

vscode中创建vue快捷键

1.安装Vetur插件(扩展里面直接搜) 2.vscode 界面里面左上角选则 文件=> 首选项=> 用户代码片段=>新建全局代码片段=>在输入框中新建名称为vue.json 3.删除里面的注释,当然你也可以留着,把下面的代码粘贴进去! { // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // descri

Leon_940002463的博客 3207

R语言影像组学实战:从医学图像到预测模型的完整流程(附代码)

本文详细介绍了使用R语言进行影像组学分析的完整实战流程。从环境搭建、数据准备,到医学图像的特征提取与筛选,再到利用机器学习构建预测模型并进行评估,提供了清晰的步骤和可运行的R代码示例,帮助研究者和数据分析师掌握从医学图像到临床预测模型的核心技术。

qsc901234的博客 732

JSP中的文件操作

目录1、File类2、读写文件的常用流1.字节输入流2.字节输出流3.字符流4.缓冲流3、RandomAccessFile类4、文件操作5、小结 1、File类 File类的对象主要用来获取文件本身的一些信息,不涉及对文件的读写操作。 创建一个File对象的构造方法有3个: File(String filename); File(String directoryPath,String filename); File(File f, String filename); 经常使用File类的下列方法获取文件本

爱吃猫的鱼~ 1305

【KingSCADA】如何建立硬件系统及相关变量

本篇主要讲解如何定义设备,如何定义变量。KingSCADA3.8的采集系统是指负责和现场设备进行通讯,并采集现场数据和控制现场数据的模块,称之为采集器,也叫IOServer应用,它是一组独立的应用程序,可以脱离KingSCADA3.8软件,它依赖于KingSCADA3.8驱动产品,通过驱动与IO设备进行通讯。采集系统由通讯链路,设备,数据块组成。链路:链路是指计算机通过什么方式(接口)与设备进行连接,链路类别:串口,以太网,GPRS,Modem,通信卡,采集卡,无链路。

做有价值的事,积累有价值的笔记! 1万+

Java——文件操作

File类在包java.io.File下,代表操作系统的文件对象(文件、文件夹File类提供了:定位文件,获取文件本身的信息、删除文件、创建文件(文件夹)等功能File类创建对象名称说明根据文件路径创建对象从父路径名字符串和子路径名字字符串创建文件对象根据父路径对应文件对象和子路径名字字符串创建对象File对象可以定位文件和文件夹File封装的对象仅仅是一个路径名,这个路径可以是存在的,也可以是不存在的Demo。

Java学不会的博客 5004

VB.net:VB.net编程语言学习之基于VS软件利用VB.net语言实现对SolidWorks进行二次开发的案例应用(启动SolidWorks代码/直接驱动模型代码/路径下模型驱动代码/创建两个文

VB.net:VB.net编程语言学习之基于VS软件利用VB.net语言实现对SolidWorks进行二次开发的案例应用(启动SolidWorks代码/直接驱动模型代码/路径下模型驱动代码/创建两个文件夹对话框代码/重新生成三维图代码/导出工程图代码)之详细攻略 目录 基于VS软件利用VB.net语言实现对SolidWorks进行二次开发的案例应用 1、调用SW的模型,并进行参数修改 1.1、VB按钮之SW的三维零件之间切换思想 1.2、调用SW 2、基础案例经验 2.1、设计SW的拉

头部AI社区如有邀博主AI主题演讲请私信—心比天高,仗剑走天涯,保持热爱,奔赴向梦想!低调,专注,谦虚,自律,反思,成长,还算比较正能量的博主,公益免费传播…内心特别想在AI界做出一些可以推进历史进程影响力的技术(兴趣使然,有点小情怀,也有点使命感呀 3036

基于高频变压器的隔离式推挽栅极驱动电路

摘要:本文介绍了一种基于高频变压器的隔离式推挽栅极驱动电路,通过变压器实现电气隔离,为功率MOS管提供可靠驱动信号。电路包含输入侧PWM信号处理、变压器磁耦合隔离传输以及副边驱动逻辑等关键部分,利用电阻电容网络控制开关速度并防止误触发。该隔离驱动方案广泛应用于高压开关电源、新能源汽车电机控制器、光伏逆变器和工业变频器等需要高电压隔离及抗干扰能力的电力电子设备中,有效保障系统安全性和可靠性。

qq_37999850的博客 481

JAVA 文件操作

平常经常使用JAVA对文件进行读写等操作,这里汇总一下常用的文件操作。 1、创建文件 public static boolean createFile(String filePath){ boolean result = false; File file = new File(filePath); if(!file.exists()){ try { res

brushli的专栏 1万+

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...

Java 文件操作详解

本文将详细介绍 Java 中的文件操作,从 `java.io.File` 类到 `RandomAccessFile`,再到第三方库如 Apache Commons IO 和 Hutool 的使用。

专注Java和MySQL领域知识分享 1082

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java文件操作

数据流是一串连续的数据集合,就像水池里的水流,在一端水管供水(即写数据),在另一端水管出水(即读数据)。在写入数据时,可以一点一点或一段一段地写入,这些数据会按照先后顺序形成一个长的数据流,则在读取数据时,可以读取任意长度的数据Java标准库对流进行了一系列的封装,提供了一系列类来完成这些工作,而这些类大体可以分为两大类:1.

2301_76161469的博客 1517

STM32F407中文手册

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

JAVA文件操作

Java文件操作

WangSir 874

java 文件操作类_Java文件操作大全

//1.创建文件夹//import java.io.*;File myFolderPath = newFile(str1);try{if (!myFolderPath.exists()) {myFolderPath.mkdir();}}catch(Exception e) {System.out.println("新建目录操作出错");e.printStackTrace();}//2.创建文件//...

weixin_31009269的博客 123

【Java文件操作】文件操作常用API

包含Java使用流对象操作文件的一系列常用方法

weixin_62533201的博客 1146

Java语言的文件操作

通过以上示例,我们全面了解了Java进行文件操作的基本方法和技巧。异常处理:文件操作是IO密集型的操作,可能因为权限、路径错误等原因导致异常,因此要妥善处理异常。资源管理:使用语句可以确保在使用完流后自动关闭,避免资源泄露。编码问题:在处理文本文件时,需要注意字符编码的选择和一致性,避免出现乱码。性能优化:对于大文件的读写,可以考虑使用Buffered流来提高性能。

2501_90426037的博客 412

java文件操作大全_Java文件操作大全

//1.创建文件夹//import java.io.*;File myFolderPath = new File(str1);try {if (!myFolderPath.exists()) {myFolderPath.mkdir();}}catch (Exception e) {System.out.println("新建目录操作出错");e.printStackTrace();}//2.创建文...

weixin_29528865的博客 161
上一篇: 手动排序的数据库保存
下一篇: java ArrayList排序
wiregate
博客等级 码龄22年 7粉丝 80原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值