barriers / 阅读 / 详情

如何在eclipse中创建"properties"文件?

2023-07-23 03:18:36
共1条回复
阿啵呲嘚

建个.txt文件后,缀改成.properties 粘贴进去就可以了。

具体操作方法如下:

1.点击new-file,弹出如下图所示对话框,选择好文件存放路径和文件名即可。

properties

2..properties .xml文件都是用来存储信息用的 ,区别只是读取的方式不同而已;就比方说你写了段文件可以存为文本, 也可以存为word 看的时候用不同的程序读取而已。

相关推荐

properties是什么意思

财产 产权 房地产
2023-07-22 15:02:558

properties是什么意思

正确
2023-07-22 15:03:124

properties是什么意思

properties[英][p"ru0252pu0259tu026az][美][p"ru0252pu0259tu026az]n.特性; 财产; 房地产(property的名词复数); 所有权; 以上结果来自金山词霸例句:1.Mainland retail properties have since become a hot target for foreign funds and investors. 自此之后,中国内地零售业地产成为海外基金和投资者追捧的对象
2023-07-22 15:03:221

properties翻译成中文

properties翻译成中文:物业。"物业"一词译自英语property或estate,由香港传入沿海、内地,其含义为财产、资产、地产、房地产、产业等。该词自20世纪80年代引入国内,现已形成了一个完整的概念,即:物业是指已经建成并投入使用的各类房屋及其与之相配套的设备、设施和场地。物业可大可小,一个单元住宅可以是物业,一座大厦也可以作为一项物业,同一建筑物还可按权属的不同分割为若干物业。
2023-07-22 15:03:291

java中的Properties是什么类呢,什么意思呢

properties 如上面所说,一般和文件相关这个文件比较特殊,必须是键值对的形式就像windows 里的 .ini文件一样如:window=800*600screen=1左边键名,右边值,用等号连接properties 读取文件后,会存为一个个键值对的形式,key=window value=800*600等.
2023-07-22 15:03:392

altiumdesigner怎么打开properties

altiumdesigner怎么打开properties如下。1、在菜单栏中选择View->Panels->Properties,或者使用快捷键P,即可打开Properties面板。2、在Properties面板中,可以查看和编辑所选对象的属性,如位置、尺寸、参考设计ator、电气属性等。3、需要注意的是,Properties面板的显示内容和可编辑属性取决于所选对象的类型和属性设置。4、如果Properties面板没有显示所需的属性或选项,可以通过在菜单栏中选择View->Panels->Properties->Options,或者使用快捷键Alt+P,来打开Properties面板的选项设置,进行自定义设置。
2023-07-22 15:03:461

怎样在.properties文件中注释

1、打开IDEA,新建一个Web项目,右键点击新建的项目名,选择创建文件目录(Directory),一般properties文件夹命名应为resoures。2、右键点击新建的resources文件夹,弹出的窗口里选择Mark Dictory as >>Resources Root将文件夹定义为配置文件。3、也可以通过Ctrl+shift+alt+s组合件打开Project Structure面板将需要的文件夹声明为配置文件类型。4、右键点击声明为resources类型的文件夹选择Resource Bundle,就能创架一个properties文件了。5、mysql 的properties配置文件是以键值对形式存读取的,一个对象占用一行,行末不能添加分号。6、配置文件的使用。就可以注释了。
2023-07-22 15:03:551

什么是properties文件

properties是属性的意思,properties文件需要结合上下文来判断具体是指什么
2023-07-22 15:04:512

java的properties文件怎么创建

右键,new file 输入:XXXXX.properties
2023-07-22 15:05:002

properties在一个c#程序内起什么作用

属性,比字段好,因为可以设置访问权限,设置或获取
2023-07-22 15:05:072

如何查找properties文件重复的属性

有一次启动一个项目,报错说存在重复的property XXX_XXXX配置。这种情况在大项目里面有时候会碰到的,就是两个开发者之间使用了同一个名称的属性,因为Properties文件没有java的命名空间规范,所以,这种问题很难避免,那么作为一个做版本的人,怎么怎么快速查找被重复使用的属性名称呢? 可以使用find,xargs和grep命令组合: 首先使用find命令找到项目下的所有属性文件: find [项目配置文件的路径] -name "*.properties" -type f 然后xargs命令接收这些找到的文件,把他们以参数的形式传给grep grep则查找文件内容,使用-n参数能够打印所在行,那么,拼在一起: find [项目配置文件的路径] -name "*.properties" -type f -print0 | xargs -0 grep -n [属性名] 得到的结果类似于 [文件名]:[行号]:[属性所在行]
2023-07-22 15:05:151

在cad中PROPERTIES是什么意思

PROPERTIES在CAD中是特性的意思,快捷输入有“PR或MO”,快捷键“Ctrl+1”,或者选择图形,点击右键,选项最下面的特性
2023-07-22 15:05:241

如何获取properties文件

最常用读取properties文件的方法InputStream in = getClass().getResourceAsStream("资源Name");这种方式要求properties文件和当前类在同一文件夹下面。如果在不同的包中,必须使用:InputStream ins = this.getClass().getResourceAsStream("/cn/zhao/properties/testPropertiesPath2.properties");Java中获取路径方法获取路径的一个简单实现反射方式获取properties文件的三种方式1 反射方式获取properties文件最常用方法以及思考:Java读取properties文件的方法比较多,网上最多的文章是"Java读取properties文件的六种方法",但在Java应用中,最常用还是通过java.lang.Class类的getResourceAsStream(String name) 方法来实现,但我见到众多读取properties文件的代码中,都会这么干:InputStream in = getClass().getResourceAsStream("资源Name");这里面有个问题,就是getClass()调用的时候默认省略了this!我们都知道,this是不能在static(静态)方法或者static块中使用的,原因是static类型的方法或者代码块是属于类本身的,不属于某个对象,而this本身就代表当前对象,而静态方法或者块调用的时候是不用初始化对象的。问题是:假如我不想让某个类有对象,那么我会将此类的默认构造方法设为私有,当然也不会写别的共有的构造方法。并且我这个类是工具类,都是静态的方法和变量,我要在静态块或者静态方法中获取properties文件,这个方法就行不通了。
2023-07-22 15:05:401

怎么使用C语言读取properties配置文件

用C语言读取properties配置文件的方法:1、找到配置路径下的properties文件2、按行读取文件内容具体实现代码如下://定义读入的行数组,1024行char line[1024];//存放配置项数组settingint setting[N],i = 0;//开始循环读入while(fgets(fp,line,1024) != NULL){ //读入配置的值给line变量 fscanf(line,"setting%*d = %d",&setting[i++]);}
2023-07-22 15:05:501

java中的properties文件放在哪

随便放在哪里,只要路径写对就可以;比如你直接放到src下prop.load(new FileInputStream( "database.properties "));如果放到你的包里就要写出包的路径:prop.load(new FileInputStream( "../myPackage/database.properties ")); 技术问题可以去itjob技术交流群探讨
2023-07-22 15:06:101

怎样在.properties文件中写中文呢

properties文件是这么写的吗。。,应该是key=value行式的吧。注释则是开头用"#"井号比如### valid values are: true, false (true is the default)struts.objectFactory.spring.useClassCache = true另外,在属性文件中是不能写入中文的,即使写入了中文,读出来的也是乱码(注释除外,注释是给人看的,不是让程序来读的)。而你之所以写进去的中文自动转成了Unicode编码,可能是用eclipse的properties editor的添加编辑界面添加导致的(如下图),该界面本来就是增加属性文件的属性用的。如果是要加注释,需点击下面的source标签,切换到文本编辑模式,在要加注释的项之前插入一行,首字符为"#",然后输入你的中文注释即可
2023-07-22 15:06:201

如何在eclipse中创建.properties文件

 方法如下:点击new-file弹出如下图所示对话框,选择好文件存放路径和文件名即可,别的文件
2023-07-22 15:06:303

在Eclipse中怎么将*.properties文件中输入属性中文读取出来

不知道你说是不是关于国际化的问题。
2023-07-22 15:07:073

急急急!!怎么让PROPERTIES文件在手机上应用(读取)?

android中读取properties文件-摘自安卓java中经常用到properties文件,然后通过使用Properties类来解析,这里不再陈述使用properties文件的好处,主要探讨如何在android中使用properties文件! 方法一:因为最终是通过流文件来进行properties文件读取的,所以很自然,我们想到要将文件放入到assets文件夹或者raw文件夹中了。 例如,我们这里有一个文件——>test.properties,如果放入了assets文件夹中,可以如下打开Properties pro = new Properties();InputStream is = context.getAssets().open("test.properties"); pro.load(is); 如果放入到raw文件夹中,可以通过如下方式打开InputStream is = context.getResources().openRawResource(R.raw.test); 但是,有的时候我们不想获取android的上下文环境(context),而是像java中标准的方法加载properties文件,那么我们如何使用呢?请看方法二: 方法二:没有上下文的加载![推荐方式]Properties pro = new Properties();pro.load(FileLoad.class.getResourceAsStream("test.properties"));其中,FileLoad是该加载方法所在类的类名。test.properties所存放的路径与FileLoad.java为同一包中。但是,在android中,当我们打包生成apk后,将apk放入到真正的手机上时,你会找不到test.properties文件,不要惊讶,android中的资源文件是只能存放在assets或者res的子目录里面的,程序包中的资源文件编译后,是会丢失的!那么是不是我们的第二种方法就没法使用了? 当然不是,经过实验发现,将文件放入到assets文件夹里,而在传入路径里面填入文件绝对路径,还是可以引用该文件的。代码:pro.load(FileLoad.class.getResourceAsStream("/assets/test.properties")); 注意:其中工程路径的根路径为"/"如此一来,你就可以顺利使用你的Properties文件了!
2023-07-22 15:07:161

怎么使用C语言读取properties配置文件

void read_properties(char *pathname, char names[100][100], char values[100][100]){ FILE *file; char line[100]; int i = 0; file = fopen(pathname, "r"); while(fgets(line, 100, file)){ printf("%s", line); //just for test, delete it later. parseline(line, names[i], values[i]); i++; } fclose(file);}//其实 Windows平台,一般使用.ini的配置 文件
2023-07-22 15:07:262

用Servlet读取Properties文件为什么Properties.load方法报错

myeclipse中prop.load报错是因为没有找到要加载的properties文件。Java可使用Properties类读写properties,具体说明如下:1.Properties类与Properties配置文件  Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值对的形式来保存属性集。不过Properties有特殊的地方,就是它的键和值都是字符串类型。2.Properties中的主要方法(1)load(InputStream inStream)  这个方法可以从.properties属性文件对应的文件输入流中,加载属性列表到Properties类对象。如下面的代码:Properties pro = new Properties();FileInputStream in = new FileInputStream("a.properties");pro.load(in);in.close();(2)store(OutputStream out, String comments)  这个方法将Properties类对象的属性列表保存到输出流中。如下面的代码:FileOutputStream oFile = new FileOutputStream(file, "a.properties");pro.store(oFile, "Comment");oFile.close();  如果comments不为空,保存后的属性文件第一行会是#comments,表示注释信息;如果为空则没有注释信息。  注释信息后面是属性文件的当前保存时间信息。(3)getProperty/setProperty  这两个方法是分别是获取和设置属性信息。3.代码实例属性文件a.properties如下:name=rootpass=liukey=value读取a.properties属性列表,与生成属性文件b.properties。代码如下:import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.InputStream;import java.util.Iterator;import java.util.Properties;public class PropertyTest {public static void main(String[] args) {try {// 读取属性文件a.propertiesInputStream in = new BufferedInputStream(new FileInputStream("a.properties"));// /加载属性列表Properties prop = new Properties();prop.load(in);Iterator<String> it = prop.stringPropertyNames().iterator();while (it.hasNext()) {String key = it.next();System.out.println(key + ":" + prop.getProperty(key));}in.close();// /保存属性到b.properties文件FileOutputStream oFile = new FileOutputStream("b.properties", true);// true表示追加打开prop.setProperty("phone", "10086");prop.store(oFile, "The New properties file");oFile.close();} catch (Exception e) {System.out.println(e);}}}
2023-07-22 15:07:331

怎么在eclipse中安装properties插件

资源文件 即 .properties 文件是常用于国际化;eclipse默认的 .properties 文件编辑器有几个问题:编码问题多种语言同步问题下面介绍2种eclipse的 .properties 文件的插件,可以方便的编辑 .properties 文件(1) PropEditPropEdit,可以解决 编码问题,也就是说它可以自动将各种语言转化成所需的编码格式安装方法(更新方式):利用eclipse的更新功能,地址为 http://propedit.sourceforge.jp/eclipse/updates/步骤如下:1、展开Eclipse的Help菜单,将鼠标移到Software Update子项,在出现的子菜单中点击Find and Install;2、在Install/Update对话框中选择Search for new features to install,点击Next;3、在Install对话框中点击New Remote Site;4、在New Update Site对话框的Name填入“PropEdit”或其它任意非空字符串,在URL中填入http://propedit.sourceforge.jp/eclipse/updates/;5、在Site to include to search列表中,除上一步加入的site外的其它选项去掉,点击Finsih;6、在弹出的Updates对话框中的Select the features to install列表中将所有结尾为“3.1.x”的选项去掉(适用于Eclipse 3.2版本的朋友);7、点击Finish关闭对话框;8、在下载后,同意安装,再按提示重启Eclipse,在工具条看到形似vi的按钮表示安装成功,插件可用。此时,Eclpise中所有properties文件的文件名前有绿色的P的图标作为标识。注意:最新的 propedit 不支持 myeclipse6.5 ,必须 下载旧版的进行安装;http://sourceforge.jp/projects/propedit/downloads/36845/jp.gr.java_conf.ussiy.app.propedit_5.0.1.zip(2)JIntoJInto 可以同时解决 编码问题 和 多种语言同步问题安装方法(link方式):* 下载包,地址:http://www.guh-software.de/jinto_en.html* 下面以安装在 d:/myeclipse6.5/ext-link/ 目录下为例* 首先在 d:/myeclipse6.5/ext-link/ 下建立一个目录,名为 “jinto”* 解压 下载的包,可以看到包下有 “eclipse”目录,“eclipse”目录下又有“plugins”和“features”目录;* 将 “eclipse”目录放到“jinto”目录下* 新建1个link文件,名为 jinto.link ,放在 eclipse安装的根目录下的 link文件夹里;* jinto.link 里写1行内容,即 “path=d:/myeclipse6.5/ext-link/jinto”* 重启 eclipse或myeclipse(3)设置默认的 .properties文件编辑器eclipse中, window->preferences->General->Editors->File Asssociations ,找到 .properties ,选中相应的编辑器,点击 “default”按钮;其中 “jinto”对应的编辑器名是“Java ResourceBundle Editor” ,“ PropEdit”对应的编辑器名是“PropertiesEditor”
2023-07-22 15:07:422

如何使用properties文件

方法一:因为最终是通过流文件来进行properties文件读取的,所以很自然,我们想到要将文件放入到assets文件夹或者raw文件夹中了。 例如,我们这里有一个文件——>test.properties,如果放入了assets文件夹中,可以如下打开 Properties pro = new P...
2023-07-22 15:08:001

如何在Android开发中对properties文件进行读取

android中读取properties就简单多了,不过不建议用properties 因为apk是要打包的,也就是说,properties文件要在自己的应用程序发布之前打包进去读取方式:1. 将 properties文件复制到res/raw目录下2. 调用android api 获取raw下的输入流3.Properties pr = new Properties();try { pr.load(getResources().openRawResource(R.raw.test)); //resources中打开一个输入流,这个输入流就是自己的properties文件} catch (IOException e) { e.printStackTrace();}
2023-07-22 15:08:091

如何写一个.properties文件,如何调用

properties属性文件内容都是以键值对形式存在的,比如我写一个叫test.properties的文件,打开后可以再里面写如:name=Tom而在java类中需要new一个Properties类的对象,如下:Properties properties = new Properties();接下来需要获取test.properties的文件路径:String path = Thread.currentThread().getContextClassLoader().getResource("test.properties").getPath();然后加载该文件:properties.load(new FileInputStream(path));最后你就可以get它的属性了:String name_1=properties.getProperty("name");这个name_1的值就是“TOM”了。(因为涉及到文件流,所以加载那一步需要try catch,根据编译器提示自己加吧)
2023-07-22 15:08:191

怎么将properties文件解析成map,并打印到控制台

type.propertiesleft=factorymethod.LeftHairright=factorymethod.RightHairin=factorymethod.InHairimport java.io.InputStream;import java.util.Enumeration;import java.util.HashMap;import java.util.Map;import java.util.Properties;//读取properties内容并转换成map形式public class PropertiesReader {public Map<String, String> getProperties(){Properties props = new Properties();Map<String, String> map=new HashMap<String, String>();try {InputStream in= getClass().getResourceAsStream("Type.properties");props.load(in);Enumeration en=props.propertyNames();while (en.hasMoreElements()) {String key=(String) en.nextElement();String property=props.getProperty(key);map.put(key, property);System.out.println(key + "."+property);}} catch (Exception e) {// TODO: handle exception}return map;}}public HairInterface getHairByClassKey(String key){try {Map<String, String> map=new PropertiesReader().//getProperties();HairInterface hair= (HairInterface) //Class.forName(map.get(key)).newInstance();return hair;} catch (InstantiationException e) {e.printStackTrace();}catch (IllegalAccessException e) {e.printStackTrace();}catch (ClassNotFoundException e) {e.printStackTrace();}return null;}
2023-07-22 15:08:281

请问用vs2008创建项目时的properties文件夹和它里面的文件有什么用?

Properties文件夹 定义你程序集的属性 项目属性文件夹 一般只有一个 AssemblyInfo.cs 类文件,用于保存程序集的信息,如名称,版本等,这些信息一般与项目属性面板中的数据对应,不需要手动编写。
2023-07-22 15:08:351

java中用Properties类加载配置文件

一个Properties只能加载一个问题,如果你需要加载多个的话只能多写几个了。例如:Propertiesprop=newProperties();prop.load(ConfigUtil.class.getClassLoader().getResourceAsStream("config.properties"));Propertiesprop1=newProperties();prop1.load(ConfigUtil.class.getClassLoader().getResourceAsStream("config.properties1"));
2023-07-22 15:09:151

怎样在.properties文件中注释

怎样在.properties文件中注释写回答有奖励 共4个回答百度网友f4b5898 高能答主 2019-06-12 致力于成为全知道最会答题的人关注1、打开IDEA,新建一个Web项目,右键点击新建的项目名,选择创建文件目录(Directory),一般properties文件夹命名应为resoures。2、右键点击新建的resources文件夹,弹出的窗口里选择Mark Dictory as >>Resources Root将文件夹定义为配置文件。3、也可以通过Ctrl+shift+alt+s组合件打开Project Structure面板将需要的文件夹声明为配置文件类型。4、右键点击声明为resources类型的文件夹选择Resource Bundle,就能创架一个properties文件了。5、mysql 的properties配置文件是以键值对形式存读取的,一个对象占用一行,行末不能添加分号。6、配置文件的使用。就可以注释了。
2023-07-22 15:10:078

c盘里的properties可以删除吗

  properties是配置文件,主要的作用是通过修改配置文件可以方便的修改代码中的参数,实现不用改class文件即可灵活变更参数。  解释:java运行中java文件会变成class文件,之后无法通过反编译找到原样的代码,这样的话,如果java类中某个参数变更,就很难灵活的实现参数修改,这个时候properties 文件就能很灵活的实现配置,减少代码的维护成本和提高开发效率。
2023-07-22 15:10:591

如何在spring中读取properties配置文件里面的信息

如何在spring中读取properties配置文件里面的信息<!-- 正文开始 -->一般来说。我们会将一些配置的信息放在。properties文件中。然后使用${}将配置文件中的信息读取至spring的配置文件。那么我们如何在spring读取properties文件呢。1.首先。我们要先在spring配置文件中。定义一个专门读取properties文件的类.例: <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> <!--要是有多个配置文件,只需在这里继续添加即可 --> </list> </property> </bean>这里为什么用locations(还有一个location)是因为。一般来说。我们的项目里面。配置文件可能存在多个。就算是只有一个。那将来新添加的话。只需在下面再加一个value标签即可。而不必再重新改动太多。(当然。性能上是否有影响,这个以当前这种服务器的配置来说。是基科可以忽略不计的)。然后我们就可以在jdbc.properties文件中填写具体的配置信息了。 <!-- 配置C3P0数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>${jdbc.driverClassName}</value> </property> <property name="jdbcUrl"> <value>${jdbc.url}</value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> </bean>jdbc.properties文件写的信息。jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/testjdbc.username=rootjdbc.password=root附加一个列子: <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>file:/data/pc-config/passport.properties</value> <value>classpath:memcached.properties</value> </list> </property> </bean>classpath:是指的当前类文件的目录下。file:在window下是指的当前分区(比如你的项目是放在d盘,则是在d:/data/pc-config/passport.properties) 在linux下,则是当前路径下的文件/data/pc-config/passport.properties
2023-07-22 15:11:071

怎么读取properties文件

最常用读取properties文件的方法InputStream in = getClass().getResourceAsStream("资源Name");这种方式要求properties文件和当前类在同一文件夹下面。如果在不同的包中,必须使用:InputStream ins = this.getClass().getResourceAsStream("/cn/zhao/properties/testPropertiesPath2.properties");Java中获取路径方法获取路径的一个简单实现反射方式获取properties文件的三种方式1 反射方式获取properties文件最常用方法以及思考:Java读取properties文件的方法比较多,网上最多的文章是"Java读取properties文件的六种方法",但在Java应用中,最常用还是通过java.lang.Class类的getResourceAsStream(String name) 方法来实现,但我见到众多读取properties文件的代码中,都会这么干:InputStream in = getClass().getResourceAsStream("资源Name");这里面有个问题,就是getClass()调用的时候默认省略了this!我们都知道,this是不能在static(静态)方法或者static块中使用的,原因是static类型的方法或者代码块是属于类本身的,不属于某个对象,而this本身就代表当前对象,而静态方法或者块调用的时候是不用初始化对象的。问题是:假如我不想让某个类有对象,那么我会将此类的默认构造方法设为私有,当然也不会写别的共有的构造方法。并且我这个类是工具类,都是静态的方法和变量,我要在静态块或者静态方法中获取properties文件,这个方法就行不通了。
2023-07-22 15:11:141

在java中如何读取properties文件

最常用读取properties文件的方法InputStream in = getClass().getResourceAsStream("资源Name");这种方式要求properties文件和当前类在同一文件夹下面。如果在不同的包中,必须使用:InputStream ins = this.getClass().getResourceAsStream("/cn/zhao/properties/testPropertiesPath2.properties");Java中获取路径方法获取路径的一个简单实现反射方式获取properties文件的三种方式1 反射方式获取properties文件最常用方法以及思考:Java读取properties文件的方法比较多,网上最多的文章是"Java读取properties文件的六种方法",但在Java应用中,最常用还是通过java.lang.Class类的getResourceAsStream(String name) 方法来实现,但我见到众多读取properties文件的代码中,都会这么干:InputStream in = getClass().getResourceAsStream("资源Name");这里面有个问题,就是getClass()调用的时候默认省略了this!我们都知道,this是不能在static(静态)方法或者static块中使用的,原因是static类型的方法或者代码块是属于类本身的,不属于某个对象,而this本身就代表当前对象,而静态方法或者块调用的时候是不用初始化对象的。问题是:假如我不想让某个类有对象,那么我会将此类的默认构造方法设为私有,当然也不会写别的共有的构造方法。并且我这个类是工具类,都是静态的方法和变量,我要在静态块或者静态方法中获取properties文件,这个方法就行不通了。那怎么办呢?其实这个类就不是这么用的,他仅仅是需要获取一个Class对象就可以了,那还不容易啊-- 取所有类的父类Object,用Object.class难道不比你的用你正在写类自身方便安全吗 ?呵呵,下面给出一个例子,以方便交流。 import java.util.Properties; import java.io.InputStream; import java.io.IOException;/** * 读取Properties文件的例子 * File: TestProperties.java * User: leizhimin * Date: 2008-2-15 18:38:40 */ public final class TestProperties {private static String param1;private static String param2;static {Properties prop = new Properties();InputStream in = Object. class .getResourceAsStream( "/test.properties" );try {prop.load(in);param1 = prop.getProperty( "initYears1" ).trim();param2 = prop.getProperty( "initYears2" ).trim();} catch (IOException e) {e.printStackTrace();}}/*** 私有构造方法,不需要创建对象*/private TestProperties() {}public static String getParam1() {return param1;}public static String getParam2() {return param2;}public static void main(String args[]){System.out.println(getParam1());System.out.println(getParam2());} } 运行结果:151 152 当然,把Object.class换成int.class照样行,呵呵,大家可以试试。另外,如果是static方法或块中读取Properties文件,还有一种最保险的方法,就是这个类的本身名字来直接获取Class对象,比如本例中可写成TestProperties.class,这样做是最保险的方法2 获取路径的方式:File fileB = new File( this .getClass().getResource( "" ).getPath());System. out .println( "fileB path: " + fileB); 2.2获取当前类所在的工程名:System. out .println("user.dir path: " + System. getProperty ("user.dir"))<span style="background-color: white;">3 获取路径的一个简单的Java实现</span> /***获取项目的相对路径下文件的绝对路径** @param parentDir*目标文件的父目录,例如说,工程的目录下,有lib与bin和conf目录,那么程序运行于lib or* bin,那么需要的配置文件却是conf里面,则需要找到该配置文件的绝对路径* @param fileName*文件名* @return一个绝对路径*/public static String getPath(String parentDir, String fileName) {String path = null;String userdir = System.getProperty("user.dir");String userdirName = new File(userdir).getName();if (userdirName.equalsIgnoreCase("lib")|| userdirName.equalsIgnoreCase("bin")) {File newf = new File(userdir);File newp = new File(newf.getParent());if (fileName.trim().equals("")) {path = newp.getPath() + File.separator + parentDir;} else {path = newp.getPath() + File.separator + parentDir+ File.separator + fileName;}} else {if (fileName.trim().equals("")) {path = userdir + File.separator + parentDir;} else {path = userdir + File.separator + parentDir + File.separator+ fileName;}} return path;} 4 利用反射的方式获取路径:InputStream ips1 = Enumeration . class .getClassLoader() .getResourceAsStream( "cn/zhao/enumStudy/testPropertiesPath1.properties" ); InputStream ips2 = Enumeration . class .getResourceAsStream( "testPropertiesPath1.properties" ); InputStream ips3 = Enumeration . class .getResourceAsStream( "properties/testPropertiesPath2.properties" );
2023-07-22 15:11:241

eclipse怎么添加驱动利用properties

方法如下,请先保证oracle可以正常运行。  2  打开Eclipse,找到“Window”--“Show View”--“Other...”  3  在弹出的新窗口中,打开文件夹“Data Management”找到“Data Source Explorer”,并单击“OK”
2023-07-22 15:11:312

properties文件怎么写

InputStream in = 类名.class.getClassLoader().getResourceAsStream("propertes名字.properties"); Properties prop = new Properties(); prop.load(in) oracleDb_Driver = prop.getProperty("oracleDb_Driver-properties里面的字段");
2023-07-22 15:11:381

如何在spring中读取properties配置文件里面的信息

  一般来说。我们会将一些配置的信息放在。properties文件中。然后使用${}将配置文件中的信息读取至spring的配置文件。那么我们如何在spring读取properties文件呢。1.首先。我们要先在spring配置文件中。定义一个专门读取properties文件的类.例: <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> <!--要是有多个配置文件,只需在这里继续添加即可 --> </list> </property> </bean>这里为什么用locations(还有一个location)是因为。一般来说。我们的项目里面。配置文件可能存在多个。就算是只有一个。那将来新添加的话。只需在下面再加一个value标签即可。而不必再重新改动太多。(当然。性能上是否有影响,这个以当前这种服务器的配置来说。是基科可以忽略不计的)。然后我们就可以在jdbc.properties文件中填写具体的配置信息了。 <!-- 配置C3P0数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>${jdbc.driverClassName}</value> </property> <property name="jdbcUrl"> <value>${jdbc.url}</value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> </bean>jdbc.properties文件写的信息。jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/testjdbc.username=rootjdbc.password=root附加一个列子:  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>file:/data/pc-config/passport.properties</value> <value>classpath:memcached.properties</value> </list> </property> </bean>  classpath:是指的当前类文件的目录下。  file:在window下是指的当前分区(比如你的项目是放在d盘,则是在d:/data/pc-config/passport.properties)  在linux下,则是当前路径下的文件/data/pc-config/passport.properties转载仅供参考,版权属于原作者。祝你愉快,满意请采纳哦
2023-07-22 15:11:561

spring.properties文件在哪儿

一般来说。我们会将一些配置的信息放在。properties文件中。然后使用${}将配置文件中的信息读取至spring的配置文件。那么我们如何在spring读取properties文件呢。1.首先。我们要先在spring配置文件中。定义一个专门读取properties文件的类.例: <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:jdbc.properties</value> <!--要是有多个配置文件,只需在这里继续添加即可 --> </list> </property> </bean>这里为什么用locations(还有一个location)是因为。一般来说。我们的项目里面。配置文件可能存在多个。就算是只有一个。那将来新添加的话。只需在下面再加一个value标签即可。而不必再重新改动太多。(当然。性能上是否有影响,这个以当前这种服务器的配置来说。是基科可以忽略不计的)。然后我们就可以在jdbc.properties文件中填写具体的配置信息了。 <!-- 配置C3P0数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>${jdbc.driverClassName}</value> </property> <property name="jdbcUrl"> <value>${jdbc.url}</value> </property> <property name="user"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> </bean>jdbc.properties文件写的信息。jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/testjdbc.username=rootjdbc.password=root附加一个列子:  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>file:/data/pc-config/passport.properties</value> <value>classpath:memcached.properties</value> </list> </property> </bean>  classpath:是指的当前类文件的目录下。  file:在window下是指的当前分区(比如你的项目是放在d盘,则是在d:/data/pc-config/passport.properties)  在linux下,则是当前路径下的文件/data/pc-config/passport.properties转载仅供参考,版权属于原作者。祝你愉快,满意请采纳哦
2023-07-22 15:12:051

ms怎么调出properties

1、首先按下Windows键+R,调用运行窗口,输入ms-settingsabout。2、其按回车,打开“关于你的电脑”设置页面。3、然后在“设备规格”部分下,找到一个名为“设备详细信息”的链接。4、最后单击链接后就会调出系统的“properties”窗口了。
2023-07-22 15:12:121

用Servlet读取Properties文件为什么Properties.load方法报错

myeclipse中prop.load报错是因为没有找到要加载的properties文件。Java可使用Properties类读写properties,具体说明如下:1.Properties类与Properties配置文件  Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值对的形式来保存属性集。不过Properties有特殊的地方,就是它的键和值都是字符串类型。2.Properties中的主要方法(1)load(InputStream inStream)  这个方法可以从.properties属性文件对应的文件输入流中,加载属性列表到Properties类对象。如下面的代码:Properties pro = new Properties();FileInputStream in = new FileInputStream("a.properties");pro.load(in);in.close();(2)store(OutputStream out, String comments)  这个方法将Properties类对象的属性列表保存到输出流中。如下面的代码:FileOutputStream oFile = new FileOutputStream(file, "a.properties");pro.store(oFile, "Comment");oFile.close();  如果comments不为空,保存后的属性文件第一行会是#comments,表示注释信息;如果为空则没有注释信息。  注释信息后面是属性文件的当前保存时间信息。(3)getProperty/setProperty  这两个方法是分别是获取和设置属性信息。3.代码实例属性文件a.properties如下:name=rootpass=liukey=value读取a.properties属性列表,与生成属性文件b.properties。代码如下:import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.InputStream;import java.util.Iterator;import java.util.Properties;public class PropertyTest {public static void main(String[] args) {try {// 读取属性文件a.propertiesInputStream in = new BufferedInputStream(new FileInputStream("a.properties"));// /加载属性列表Properties prop = new Properties();prop.load(in);Iterator<String> it = prop.stringPropertyNames().iterator();while (it.hasNext()) {String key = it.next();System.out.println(key + ":" + prop.getProperty(key));}in.close();// /保存属性到b.properties文件FileOutputStream oFile = new FileOutputStream("b.properties", true);// true表示追加打开prop.setProperty("phone", "10086");prop.store(oFile, "The New properties file");oFile.close();} catch (Exception e) {System.out.println(e);}}}
2023-07-22 15:12:191

如何优雅读取properties文件

最常用读取properties文件的方法InputStream in = getClass().getResourceAsStream("资源Name");这种方式要求properties文件和当前类在同一文件夹下面。如果在不同的包中,必须使用:InputStream ins = this.getClass().getResourceAsStream("/cn/zhao/properties/testPropertiesPath2.properties");Java中获取路径方法获取路径的一个简单实现反射方式获取properties文件的三种方式1 反射方式获取properties文件最常用方法以及思考:Java读取properties文件的方法比较多,网上最多的文章是"Java读取properties文件的六种方法",但在Java应用中,最常用还是通过java.lang.Class类的getResourceAsStream(String name) 方法来实现,但我见到众多读取properties文件的代码中,都会这么干:InputStream in = getClass().getResourceAsStream("资源Name");这里面有个问题,就是getClass()调用的时候默认省略了this!我们都知道,this是不能在static(静态)方法或者static块中使用的,原因是static类型的方法或者代码块是属于类本身的,不属于某个对象,而this本身就代表当前对象,而静态方法或者块调用的时候是不用初始化对象的。问题是:假如我不想让某个类有对象,那么我会将此类的默认构造方法设为私有,当然也不会写别的共有的构造方法。并且我这个类是工具类,都是静态的方法和变量,我要在静态块或者静态方法中获取properties文件,这个方法就行不通了。那怎么办呢?其实这个类就不是这么用的,他仅仅是需要获取一个Class对象就可以了,那还不容易啊-- 取所有类的父类Object,用Object.class难道不比你的用你正在写类自身方便安全吗 ?呵呵,下面给出一个例子,以方便交流。 import java.util.Properties; import java.io.InputStream; import java.io.IOException; /** * 读取Properties文件的例子 * File: TestProperties.java * User: leizhimin * Date: 2008-2-15 18:38:40 */ public final class TestProperties { private static String param1; private static String param2; static { Properties prop = new Properties(); InputStream in = Object. class .getResourceAsStream( "/test.properties" ); try { prop.load(in); param1 = prop.getProperty( "initYears1" ).trim(); param2 = prop.getProperty( "initYears2" ).trim(); } catch (IOException e) { e.printStackTrace(); } } /** * 私有构造方法,不需要创建对象 */ private TestProperties() { } public static String getParam1() { return param1; } public static String getParam2() { return param2; } public static void main(String args[]){ System.out.println(getParam1()); System.out.println(getParam2()); } } 运行结果: 151 152 当然,把Object.class换成int.class照样行,呵呵,大家可以试试。另外,如果是static方法或块中读取Properties文件,还有一种最保险的方法,就是这个类的本身名字来直接获取Class对象,比如本例中可写成TestProperties.class,这样做是最保险的方法2 获取路径的方式:File fileB = new File( this .getClass().getResource( "" ).getPath()); System. out .println( "fileB path: " + fileB); 2.2获取当前类所在的工程名:System. out .println("user.dir path: " + System. getProperty ("user.dir"))<span style="background-color: white;">3 获取路径的一个简单的Java实现</span> /** *获取项目的相对路径下文件的绝对路径 * * @param parentDir *目标文件的父目录,例如说,工程的目录下,有lib与bin和conf目录,那么程序运行于lib or * bin,那么需要的配置文件却是conf里面,则需要找到该配置文件的绝对路径 * @param fileName *文件名 * @return一个绝对路径 */ public static String getPath(String parentDir, String fileName) { String path = null; String userdir = System.getProperty("user.dir"); String userdirName = new File(userdir).getName(); if (userdirName.equalsIgnoreCase("lib") || userdirName.equalsIgnoreCase("bin")) { File newf = new File(userdir); File newp = new File(newf.getParent()); if (fileName.trim().equals("")) { path = newp.getPath() + File.separator + parentDir; } else { path = newp.getPath() + File.separator + parentDir + File.separator + fileName; } } else { if (fileName.trim().equals("")) { path = userdir + File.separator + parentDir; } else { path = userdir + File.separator + parentDir + File.separator + fileName; } } return path; } 4 利用反射的方式获取路径:InputStream ips1 = Enumeration . class .getClassLoader() .getResourceAsStream( "cn/zhao/enumStudy/testPropertiesPath1.properties" ); InputStream ips2 = Enumeration . class .getResourceAsStream( "testPropertiesPath1.properties" ); InputStream ips3 = Enumeration . class .getResourceAsStream( "properties/testPropertiesPath2.properties" );
2023-07-22 15:12:261

java 操作 .properties 的内容

利用父类Hashtable的put(K key, V value) 添加利用父类Hashtable的remove(Object key) 删除
2023-07-22 15:12:363

java 调用properties文件怎么验证

Properties properties = new Properties();try {InputStream in = new BufferedInputStream (new FileInputStream(Constants.class.getClassLoader().getResource("").getPath()+"rootPath.properties"));properties.load(in);ROOT_PATH = properties.getProperty("rootPath");} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}
2023-07-22 15:12:431

java中的properties文件放在什么地方

JSP的应用吧?!把config.properties放到WEB-INFclasses下,然后JAVA程序中用“/config.properties”。如下:p.load(getClass().getResourceAsStream("/config.properties"));
2023-07-22 15:12:501

安卓编译时修改properties参数

在安卓编译时修改properties参数,需要在build.gradle文件中添加对应的配置,具体步骤如下:1、打开build.gradle文件,找到android节点下defaultConfig或者flavor节点下的相应配置。2、在配置中添加需要修改的properties参数。3、在命令行中执行编译命令时,添加需要修改的properties参数的值。
2023-07-22 15:13:081

android properties有什么用

Android下用Properties保存程序配置
2023-07-22 15:13:162

java.util包中的properties类是做什么用的?(通俗的解释)谢谢

properties 如上面所说,一般和文件相关这个文件比较特殊,必须是键值对的形式就像windows 里的 .ini文件一样如:window=800*600screen=1左边键名,右边值,用等号连接properties 读取文件后,会存为一个个键值对的形式,key=window value=800*600等.
2023-07-22 15:13:263

如何在properties中配置编码格式

  *.properties一般为页面消息的配置文件可以用命令直接将里面的内容变成想要的编码。  1:先建立一个*.properties文件,用想得到的编码编写文件内容;  2:在磁盘上运行文件nativezascii-encodinggb2312ApplicationResources_temp.propertiesApplicationResources_zh_CN.properties  这样就可以将gb2312编码的文字内容转化utf-8编码的内容了,将此文件放入存放配置文件的路径里面,就可以解决网页的多语言显示问题了
2023-07-22 15:13:351

在java中如何读取properties文件?

使用java.util.Propertiesx0dx0ax0dx0a1、创建一个Properties对象。x0dx0a2、使用对象的load方法加载你的property文件。x0dx0a3、使用getProperty方法取值。x0dx0a例子:x0dx0apackage com.bill.test;x0dx0ax0dx0aimport java.io.FileInputStream;x0dx0aimport java.util.Properties;x0dx0ax0dx0apublic class Test {x0dx0apublic static void main(String[] args) throws Exception{x0dx0aProperties property = new Properties();x0dx0aproperty.load(new FileInputStream("你的文件位置"));x0dx0aString value = property.getProperty("你的属性的key");x0dx0a//TODO 使用value...x0dx0a}x0dx0a}
2023-07-22 15:13:421

properties文件怎么写注释

在properties的文件中,在行首加上 # 就是注释这行,或者是用 <!-- --> 包括这行也是注释
2023-07-22 15:13:491

如何用代码设置shader的properties

实现在原来sampler2D _MainTex的地方,添加如下代码:[plain] view plain copy print?在CODE上查看代码片派生到我的代码片float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue 下面,我们使用_EmissiveColor和_AmbientColor来计算surf函数中新的c的值:[plain] view plain copy print?在CODE上查看代码片派生到我的代码片void surf (Input IN, inout SurfaceOutput o) { float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue); o.Albedo = c.rgb; o.Alpha = c.a; } 最后,我们的代码应该是这样的:[plain] view plain copy print?在CODE上查看代码片派生到我的代码片Shader "Custom/BasicDiffuse" { Properties { _EmissiveColor ("Emissive Color", Color) = (1,1,1,1) _AmbientColor ("Ambient Color", Color) = (1,1,1,1) _MySliderValue ("This is a Slider", Range(0,10)) = 2.5 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert //We need to declare the properties variable type inside of the //CGPROGRAM so we can access its value from the properties block. float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { //We can then use the properties values in our shader float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue); o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }
2023-07-22 15:13:571