帮忙写个JAVA 读写ini配置文件小程序!!!!!

帮忙写个JAVA 读写ini配置文件小程序!!!!!,第1张

其实使用 JDK 里面提供的 Properties 最方便。 相关使用方法可以自己去查看 JDK 的API文档。 package product;import javaawteventActionEvent;

import javaawteventActionListener;

import javaioFile;

import javaioFileInputStream;

import javaioFileNotFoundException;

import javaioFileOutputStream;

import javaioIOException;

import javautilProperties;import javaxswingJButton;

import javaxswingJFrame;

import javaxswingJLabel;

import javaxswingJOptionPane;

import javaxswingJTextField;public class IniReader {

private Properties properties = new Properties();

private String iniPath = "test/product/proini"; //ini 文件的路径

private JFrame jFrame = new JFrame("读取配置示例");

private JLabel jLabel1 = new JLabel("用户登录IP");

private JTextField jTextField1 = new JTextField(30);

private JLabel jLabel2 = new JLabel("端口号");

private JTextField jTextField2 = new JTextField(30);

private JLabel jLabel3 = new JLabel("TQ终端IP");

private JTextField jTextField3 = new JTextField(30);

private JLabel jLabel4 = new JLabel("端口号");

private JTextField jTextField4 = new JTextField(30);

private JLabel jLabel5 = new JLabel("WM终端IP");

private JTextField jTextField5 = new JTextField(30);

private JLabel jLabel6 = new JLabel("端口号");

private JTextField jTextField6 = new JTextField(30);

private JButton jButton1 = new JButton("取消");

private JButton jButton2 = new JButton("确定");

private void showFrame(){

try {

File file = new File(iniPath);

Systemoutprintln(filegetAbsolutePath());

propertiesload(new FileInputStream(iniPath));

} catch (FileNotFoundException e) {

Systemoutprintln("找不到该文件");

JOptionPaneshowMessageDialog(null, "保存信息出错!");

return;

} catch (IOException e) {

Systemoutprintln("文件读取错误");

JOptionPaneshowMessageDialog(null, "保存信息出错!");

return;

}

jTextField1setText(propertiesgetProperty("UserLogin"));

jTextField2setText(propertiesgetProperty("Userport"));

jTextField3setText(propertiesgetProperty("TQterminal"));

jTextField4setText(propertiesgetProperty("TQport"));

jTextField5setText(propertiesgetProperty("VMterminal"));

jTextField6setText(propertiesgetProperty("VMport"));

jButton1addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

jTextField1setText(propertiesgetProperty("UserLogin"));

jTextField2setText(propertiesgetProperty("Userport"));

jTextField3setText(propertiesgetProperty("TQterminal"));

jTextField4setText(propertiesgetProperty("TQport"));

jTextField5setText(propertiesgetProperty("VMterminal"));

jTextField6setText(propertiesgetProperty("VMport"));

}

});

jButton2addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) {

propertiessetProperty("UserLogin", jTextField1getText());

propertiessetProperty("Userport", jTextField2getText());

propertiessetProperty("TQterminal", jTextField3getText());

propertiessetProperty("TQport", jTextField4getText());

propertiessetProperty("VMterminal", jTextField5getText());

propertiessetProperty("VMport", jTextField6getText());

try {

propertiesstore(new FileOutputStream(iniPath),"");

} catch (Exception e1) {

e1printStackTrace();

Systemoutprintln("保存信息出错");

JOptionPaneshowMessageDialog(jFrame, "保存信息出错!");

}

JOptionPaneshowMessageDialog(jFrame, "保存成功!");

}

});

jFramesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

jLabel1setBounds(10, 40, 80, 30);

jTextField1setBounds(100, 40, 80, 30);

jLabel2setBounds(210, 40, 80, 30);

jTextField2setBounds(300, 40, 80, 30);

jLabel3setBounds(10, 80, 80, 30);

jTextField3setBounds(100, 80, 80, 30);

jLabel4setBounds(210, 80, 80, 30);

jTextField4setBounds(300, 80, 80, 30);

jLabel5setBounds(10, 120, 80, 30);

jTextField5setBounds(100, 120, 80, 30);

jLabel6setBounds(210, 120, 80, 30);

jTextField6setBounds(300, 120, 80, 30);

jFramegetContentPane()setLayout(null);

jFramegetContentPane()add(jLabel1);

jFramegetContentPane()add(jLabel2);

jFramegetContentPane()add(jLabel3);

jFramegetContentPane()add(jLabel4);

jFramegetContentPane()add(jLabel5);

jFramegetContentPane()add(jLabel6);

jFramegetContentPane()add(jTextField1);

jFramegetContentPane()add(jTextField2);

jFramegetContentPane()add(jTextField3);

jFramegetContentPane()add(jTextField4);

jFramegetContentPane()add(jTextField5);

jFramegetContentPane()add(jTextField6);

jButton1setBounds(100,160,60,30);

jButton2setBounds(230,160,60,30);

jFramegetContentPane()add(jButton1);

jFramegetContentPane()add(jButton2);

jFramesetBounds(200, 200, 400, 300);

jFramesetVisible(true);

}

public static void main(String[] args) {

new IniReader()showFrame();

}}

经测试,可用,正常。就是文件路径你自己配好。

微信小程序,简称小程序,英文名Mini Program,是一种不需要下载安装即可使用的应用,它实现了应用"触手可及"的梦想,用户扫一扫或搜一下即可打开应用。下面简单介绍一下开发入门

一、注册小程序账号

1、进入微信公众平台 2、点击立即注册

3、选择小程序 4、填写信息注册即可 5、绑定开发者 6进入“设置-开发设置”,获取AppID信息。 二、下载微信web开发者工具 1点击小程序后的查看详情 2、选择开发者工具 3、下载对应系统版本的应用程序 4、安装开发工具 三、编写小程序实例 1、打开工具点击小程序项目 2、填写相应信息,点击确定 3、实例目录结构 4、appjs是小程序的脚本代码(必须),可以在这个文件中监听并处理小程序的生命周期函数、声明全局变量,调用框架提供的丰富的 API。 5、appjson是对整个小程序的全局配置(必须),用来对微信小程序进行全局配置,决定页面文件的路径、窗口表现、设置网络超时时间、设置多tab等。接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成。微信小程序中的每一个页面的路径+页面名都需要写在appjson的pages中,且pages中的第一个页面是小程序的首页。 6、appwxss是整个小程序的公共样式表(非必须)。 7、indexjs 是页面的脚本文件(必须),在这个文件中我们可以监听并处理页面的生命周期函数、获取小程序实例,声明并处理数据,响应页面交互事件等。 8、indexwxml是页面结构文件(必须)。 9、indexwxss是页面样式表文件(非必须),当有页面样式表时,页面的样式表中的样式规则会层叠覆盖appwxss中的样式规则。如果不指定页面的样式表,也可以在页面的结构文件中直接使用appwxss中指定的样式规则。 10、在编辑配置好后点击真机调试 11、手机微信扫描二维码 12、自动d出调试窗口,通过真机调试能够更好的测试小程序

#include <stdioh>

#include <stringh>

#include <img alt="搜索" src=">

思路:

1,浏览FSO目录功能;

2,点击文件的时候将当前文件读取到表单;

3,你这个功能,会影响网站安全因素,你这种网站,别人入侵拿下管理权限应该不难;

重点:

1,能修改的目录必须用静态文件作为模板;

2,模板采用标签,标签中过滤特殊的动态代码,比如:<%

3,网页上的提问,一般人不会花很大的精力去给你写完整的代码,能有思路就很不错。

以上就是关于帮忙写个JAVA 读写ini配置文件小程序!!!!!全部的内容,包括:帮忙写个JAVA 读写ini配置文件小程序!!!!!、微信小程序开发入门教程|微信小程序开发主要技术、用c语言编写一个小程序,可以读入一个英文的文本文件,显示这个文件,并统计这个文件有多少个字符,多少等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/10626451.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存