public class ReadTxt {
/
@param filePath
@param state
@throws IOException
/
public void readTxt(String filePath, PreparedStatement state)
throws IOException {
FileReader f = new FileReader(filePath);
BufferedReader bufferedreader = new BufferedReader(
(new InputStreamReader(new FileInputStream(new File(filePath)),
"utf-8")));//编码方式为utf-8,txt保存时编码方式也要选择为utf-8
String instring;
String[] strArr = null;
while ((instring = bufferedreaderreadLine()) != null) {
if (0 != instringlength()) {
strArr = instringsplit(" ");//与txt文件中的分隔符要一致
addDataToState(strArr,state);
}
}
fclose();
}
/
添加数据到state预编译语句
@param strArr
@param state
/
public void addDataToState(String[] strArr, PreparedStatement state) {
try {
statesetString(1, strArr[0]);
statesetString(2, strArr[1]);
statesetString(3, strArr[3]);
} catch (SQLException e) {
eprintStackTrace();
}
}
public void saveData(String filePath) {
Connection conn = null;// 得到你的数据库连接
PreparedStatement state = null;
try {
connsetAutoCommit(false);// 设置手动提交事务
state = conn
prepareStatement("insert into t_student(name,sex,age) values(,,)");
thisreadTxt(filePath, state);//第一个参数为txt文件路径
conncommit();//提交数据
} catch (Exception e) {
eprintStackTrace();
} finally {
close(conn, state);
}
}
public void close(Connection conn, PreparedStatement state) {
try {
if (conn != null) {
connclose();
conn = null;
}
if (state != null) {
stateclose();
state = null;
}
} catch (SQLException e) {
eprintStackTrace();
}
}
public static void main(String[] args) {
ReadTxt rt = new ReadTxt();
rtsaveData("");//参数为你的txt文件路径
}
}
你的txt文档格式必须是:
姓名 性别 年龄
中间用“ ”隔开,如有变动需改变程序
不懂的可以发我邮箱:ucfjepl@126com
在电脑版微信中打开小程序并预览PDF,此时,这个PDF文件将保存到微信文件的默认保存位置中,一般是 C:\Users\Administrator\Documents\WeChat Files,你在这个文件夹中搜“pdf”即可。
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemIO;
using SystemWindowsForms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 当某个选项卡被取消选中时
/// </summary>
private void tabControl1_Deselected(object sender, TabControlEventArgs e)
{
eTabPageText = eTabPageTextTrimStart('');
}
/// <summary>
/// 当某个选项卡被选中时
/// </summary>
private void tabControl1_Selected(object sender, TabControlEventArgs e)
{
eTabPageText = "" + eTabPageText;
}
/// <summary>
/// 打开文件
/// </summary>
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1ShowDialog() == DialogResultOK)
{
//取得当前的选项卡数目
int tabPageCount = thistabControl1TabPagesCount;
//取得欲打开的文件路径
string filePath = thisopenFileDialog1FileName;
//取得欲打开的文件名
string fileName = PathGetFileName(filePath);
//分析是否为txt格式的文件
if (PathGetExtension(filePath)ToLower() != "txt")
{
MessageBoxShow("非法文件格式!","打开文件失败",MessageBoxButtonsOK,MessageBoxIconStop);
return;
}
//采用"page"加上当前的选项卡数目加1做为选项卡的名称
string currentPageName = "page" + (tabPageCount + 1)ToString();
//采用"richTextBox"加上当前的选项卡数目加1做为选项卡中包含RichTextBox的名称
string currentTxtName = "richTextBox" + (tabPageCount + 1)ToString();
//添加一个新的选项卡,并指定其选项卡显示文字为当前打开的文件名
thistabControl1TabPagesAdd(currentPageName,fileName);
//实例化一个新的RichTextBox
RichTextBox ricTxt = new RichTextBox();
//设置其名称,布局等属性
ricTxtName = currentTxtName;
ricTxtDock = DockStyleFill;
//ricTxtTextChanged +=
//将新这个新的RichTextBox对象添加到当前新建的选项卡中
thistabControl1TabPages[currentPageName]ControlsAdd(ricTxt);
//将文件加载到当前的RichTextBox
ricTxtLoadFile(filePath,RichTextBoxStreamTypePlainText);
}
}
private void changePageText(string currentPageName)
{
thistabControl1TabPages[currentPageName]Text = "" + currentPageName;
}
}
}
namespace WindowsApplication2
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private SystemComponentModelIContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
componentsDispose();
}
baseDispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
thistabControl1 = new SystemWindowsFormsTabControl();
thisbutton1 = new SystemWindowsFormsButton();
thisopenFileDialog1 = new SystemWindowsFormsOpenFileDialog();
thisSuspendLayout();
//
// tabControl1
//
thistabControl1Location = new SystemDrawingPoint(0, -3);
thistabControl1Name = "tabControl1";
thistabControl1SelectedIndex = 0;
thistabControl1Size = new SystemDrawingSize(540, 510);
thistabControl1TabIndex = 0;
thistabControl1Selected += new SystemWindowsFormsTabControlEventHandler(thistabControl1_Selected);
thistabControl1Deselected += new SystemWindowsFormsTabControlEventHandler(thistabControl1_Deselected);
//
// button1
//
thisbutton1Location = new SystemDrawingPoint(22, 509);
thisbutton1Name = "button1";
thisbutton1Size = new SystemDrawingSize(75, 23);
thisbutton1TabIndex = 1;
thisbutton1Text = "浏览";
thisbutton1UseVisualStyleBackColor = true;
thisbutton1Click += new SystemEventHandler(thisbutton1_Click);
//
// openFileDialog1
//
thisopenFileDialog1FileName = "openFileDialog1";
//
// Form1
//
thisAutoScaleDimensions = new SystemDrawingSizeF(6F, 12F);
thisAutoScaleMode = SystemWindowsFormsAutoScaleModeFont;
thisClientSize = new SystemDrawingSize(539, 540);
thisControlsAdd(thisbutton1);
thisControlsAdd(thistabControl1);
thisName = "Form1";
thisText = "Form1";
thisResumeLayout(false);
}
#endregion
private SystemWindowsFormsTabControl tabControl1;
private SystemWindowsFormsButton button1;
private SystemWindowsFormsOpenFileDialog openFileDialog1;
}
}
taro单独为某个项目切换taro版本环境
单独为某一个项目升级#这样做的好处是全局的 Taro 版本还是 1x 的,多个项目间的依赖不冲突,其余项目依然可以用旧版本开发。 如果你的项目里没有安装 Taro CLI,你需要先装一个:
# 如果你使用 NPM
$ npm install --save-dev @tarojs/cli@2x
# 如果你使用 Yarn
$ yarn add -D @tarojs/cli@2x
echarts在小程序中滑动卡顿
由于微信小程序中,echarts的层级最高,无论设置多大层级也无法遮住echarts。而且小程序中好像只能用echarts吧。所以为了解决这个bug,我只能委屈求全了。打开ec-canvaswxml文件,将touchStart、touchMove和touchEnd去掉了,直接删除就好啦。这三个事件应该是做缩放的吧,我们也没有这个缩放的需求。所以就去掉了。虽然暂时满足的需求,还是没有真正的解决问题。
原:
bindinit="init"
bindtouchstart="{{ ecdisableTouch '' : 'touchStart' }}"
bindtouchmove="{{ ecdisableTouch '' : 'touchMove' }}"
bindtouchend="{{ ecdisableTouch '' : 'touchEnd' }}"
现:
bindinit="init"
echarts在小程序中无法跟随页面滑动
在卡顿问题中能与echarts交互少的,可以直接使用代替cannvas,即在echarts渲染完毕后将它替换为一张。
如果我更新了数据,那么就重新放出echarts,等它渲染完毕后,再次替换为一张。
charton('finished', () => {
getCurrentInstance()pageselectComponent(id)canvasToTempFilePath({
success: res => {
consolelog('restempFilePath====',restempFilePath)
thissetState({
echartImgSrc: restempFilePath
})
},
fail: res =>consolelog('转换失败', res)
});
})
render:
thisstateechartImgSrc ==''
ref={thisrefChart}
id={thisstateid}
canvas-id="mychart-area"
force-use-old-canvas="true"
ec={thisstateec}
/>
:
<CoverImage src={thisstateechartImgSrc}></CoverImage>
前端代码:
/上传到服务器 wxuploadFile
url:后台上传文件路径地址
data:自定义参数 {'userID':'0001'}
fileName:接收数据的参数名称,后台参数类型:SystemWeb>
后台实现
/// <summary>
/// 上传 /// </summary>
/// <param name="file"></param>
/// <param name="userID"></param>
/// <returns></returns>
public string UploadImage(>
file参数里面就是数据流的信息,可自行获取之后进行保存。
以上就是关于如何用java写一个小程序,功能如下:可以把txt里面的数据导入到oracle数据库中全部的内容,包括:如何用java写一个小程序,功能如下:可以把txt里面的数据导入到oracle数据库中、微信小程序里的pdf怎么下载、利用C#编写一段读写TXT文本的小程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)