java摄像头录像保存文件夹,java swing opencv调用摄像头实现拍照及本地保存 支持上传FTP路径配置...

package com.gavin.util;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.net.URL;

import java.util.Date;

import java.util.Properties;

public class PropertiesUtil {

private static Properties properties= new Properties();

/*properties文件名*/

private static final String PROPERTIES_FILE_NAME="setting.properties";

/**

* 初始化properties,即载入数据

*/

private static void initProperties(){

try {

InputStream ips = PropertiesUtil.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE_NAME);

properties.load(ips);

ips.close();

} catch (IOException e) {

e.printStackTrace();

}

}

/**将数据载入properties,并返回key的值

* @return

*/

public static String getPrimaryKey(String key){

if(properties.isEmpty())//如果properties为空,则初始化一次。

initProperties();

return properties.getProperty(key);

}

/**修改key的值,并保存

* @param id

*/

@SuppressWarnings("deprecation")

public static void saveKeyVal(String key ,String val){

if(properties.isEmpty())

initProperties();

//修改值

properties.setProperty(key, val);

//保存文件

try {

URL fileUrl = PropertiesUtil.class.getClassLoader().getResource(PROPERTIES_FILE_NAME);//得到文件路径

FileOutputStream fos = new FileOutputStream(new File(fileUrl.toURI()));

properties.store(fos,(new Date()).toLocaleString());

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public static void main(String[] args) {

System.out.println(getPrimaryKey("local_path"));

saveKeyVal("local_path","");

System.out.println(getPrimaryKey("local_path"));

}

}

你可能感兴趣的:(java摄像头录像保存文件夹)