bug
This commit is contained in:
@@ -299,7 +299,7 @@ public static String putImg(ServletContext servletContext,MultipartFile file,Str
|
||||
//修改:原本存储在项目根路径下的,为了防止删除项目文件丢失
|
||||
//path = servletContext.getRealPath(lpath);//图片存储在项目根目录下的路径
|
||||
//现修改为:存储到固定文件夹(子路径保留),读取的时候通过url获取base64格式图片
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://webFile");
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://scbox_settings/webFile");
|
||||
if("/".equals(basePath.substring(basePath.length()-1, basePath.length()))) basePath=basePath.substring(0, basePath.length()-1);
|
||||
String np=lpath;
|
||||
if(lpath.indexOf(":")>0){
|
||||
@@ -389,7 +389,7 @@ public static String putImgAsName(ServletContext servletContext,MultipartFile fi
|
||||
//修改:原本存储在项目根路径下的,为了防止删除项目文件丢失
|
||||
//path = servletContext.getRealPath(lpath);//图片存储在项目根目录下的路径
|
||||
//现修改为:存储到固定文件夹(子路径保留),读取的时候通过url获取base64格式图片
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://webFile");
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://scbox_settings/webFile");
|
||||
if("/".equals(basePath.substring(basePath.length()-1, basePath.length()))) basePath=basePath.substring(0, basePath.length()-1);
|
||||
String np=lpath;
|
||||
if(lpath.indexOf(":")>0){
|
||||
@@ -487,7 +487,7 @@ public static String putVideo(ServletContext servletContext,MultipartFile file,S
|
||||
//修改:原本存储在项目根路径下的,为了防止删除项目文件丢失
|
||||
//path = servletContext.getRealPath(lpath);//图片存储在项目根目录下的路径
|
||||
//现修改为:存储到固定文件夹(子路径保留),读取的时候通过url获取base64格式图片
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://webFile");
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://scbox_settings/webFile");
|
||||
if("/".equals(basePath.substring(basePath.length()-1, basePath.length()))) basePath=basePath.substring(0, basePath.length()-1);
|
||||
String np=lpath;
|
||||
if(lpath.indexOf(":")>0){
|
||||
@@ -585,7 +585,7 @@ public static String putFile(ServletContext servletContext,MultipartFile file,St
|
||||
//修改:原本存储在项目根路径下的,为了防止删除项目文件丢失
|
||||
//path = servletContext.getRealPath(lpath);//图片存储在项目根目录下的路径
|
||||
//现修改为:存储到固定文件夹(子路径保留),读取的时候通过url获取base64格式图片
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://webFile");
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://scbox_settings/webFile");
|
||||
if("/".equals(basePath.substring(basePath.length()-1, basePath.length()))) basePath=basePath.substring(0, basePath.length()-1);
|
||||
String np=lpath;
|
||||
if(lpath.indexOf(":")>0){
|
||||
@@ -712,7 +712,7 @@ public static String writeFile(ServletContext servletContext, String path,
|
||||
oldfile=oldfile.substring(i+1, oldfile.length());
|
||||
}
|
||||
|
||||
String path1 = "";
|
||||
String path1 = path;
|
||||
if(path.indexOf("./")==0)
|
||||
path =path.substring(1, path.length());
|
||||
|
||||
@@ -724,7 +724,7 @@ public static String writeFile(ServletContext servletContext, String path,
|
||||
//修改:原本存储在项目根路径下的,为了防止删除项目文件丢失
|
||||
//path = servletContext.getRealPath(lpath);//图片存储在项目根目录下的路径
|
||||
//现修改为:存储到固定文件夹(子路径保留),读取的时候通过url获取base64格式图片
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://webFile");
|
||||
String basePath = ReadTxt.getSetting(null, "setting.ini", "FilePath", "D://scbox_settings/webFile");
|
||||
if("/".equals(basePath.substring(basePath.length()-1, basePath.length()))) basePath=basePath.substring(0, basePath.length()-1);
|
||||
String np=path;
|
||||
if(path.indexOf(":")>0){
|
||||
@@ -775,7 +775,7 @@ public static void delfile(ServletContext servletContext, String path) {
|
||||
if(path.indexOf("./")==0)
|
||||
path =path.substring(1, path.length());
|
||||
|
||||
String path1 = "";
|
||||
String path1 = path;
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0)
|
||||
path1 = "D:\\" + path;
|
||||
@@ -823,7 +823,7 @@ public static void delFileForStr(ServletContext servletContext, String str) {
|
||||
|
||||
path=path.replace(ReadTxt.getSetting(null, "setting.ini", "resweb", ""),"");
|
||||
|
||||
String path1 = "";
|
||||
String path1 = path;
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0)
|
||||
path1 = "D:\\" + path;
|
||||
@@ -981,7 +981,7 @@ public static ResponseEntity<FileSystemResource> returnFile(File file) {
|
||||
* @param localUrl 二维码地址
|
||||
* @return
|
||||
*/
|
||||
public String imgPS(String title,String des,String teacher,String teacherImgUrl,String localUrl) {
|
||||
public static String imgPS(String title,String des,String teacher,String teacherImgUrl,String localUrl) {
|
||||
String r=null;
|
||||
try {
|
||||
String bjUrl = "file:///C://webimg/bj.jpg";
|
||||
|
||||
@@ -3,43 +3,22 @@ package sc545.pay.utils;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
public class ReadTxt {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
//上月新增访客
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int month = cal.get(Calendar.MONTH);
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
if(month==0){
|
||||
month=12;
|
||||
year=year-1;
|
||||
}
|
||||
String ms = String.format("%02d", month);
|
||||
String ys = String.format("%04d", year);
|
||||
|
||||
String smm=ys+"-"+ms;
|
||||
String smck= ReadTxt.getSetting(null, "count.ini",smm, "0");
|
||||
|
||||
String a = ReadTxt.getSetting(null, "setting.ini", "pageNullTelTxt","提交需求");
|
||||
System.out.println(a+smm+"\n"+ms+"\n"+ys);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按行读取txt文件
|
||||
*
|
||||
* @param path
|
||||
* 文件地址(默认D:\\开头)
|
||||
* 文件地址(默认D:\\scbox_settings开头)
|
||||
* @return ArrayList 返回每行数据为一个items的集合
|
||||
*/
|
||||
public static ArrayList<String> readFileLine(ServletContext servletContext, String path) {
|
||||
@@ -49,7 +28,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -82,55 +61,12 @@ public class ReadTxt {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按行读取文件
|
||||
* debug模式
|
||||
* @param path
|
||||
* 文件地址(默认D:\\开头)
|
||||
* @return ArrayList 返回每行数据为一个items的集合
|
||||
*/
|
||||
public static ArrayList<String> readFileLineDEBUG(String path) {
|
||||
|
||||
if(path.indexOf("./")==0)
|
||||
path =path.substring(1, path.length());
|
||||
|
||||
//debug模式下把所有路径改为tomcat下的真实路径
|
||||
if(path.indexOf("/")==0){
|
||||
String tomcat_path = "D:/java/Tomcat_8.5.23/webapps/ROOT";
|
||||
path =tomcat_path+path;
|
||||
}
|
||||
|
||||
ArrayList<String> strarr = null;
|
||||
try {
|
||||
File file = new File(path);
|
||||
if (file.isFile() && file.exists()) { // 判断文件是否存在
|
||||
InputStreamReader read = new InputStreamReader(
|
||||
new FileInputStream(file), "UTF-8");
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
String lineTxt = null;
|
||||
strarr = new ArrayList<String>();
|
||||
while ((lineTxt = bufferedReader.readLine()) != null) {
|
||||
|
||||
strarr.add(lineTxt);
|
||||
}
|
||||
|
||||
read.close();
|
||||
} else {
|
||||
strarr = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return strarr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 写入txt文档,已存在就修改,否则写入末尾,自动加换行 (文件格式:key=value,换行分隔)
|
||||
*
|
||||
* @param path
|
||||
* 文件地址(默认D:\\开头)
|
||||
* 文件地址(默认D:\\scbox_settings开头)
|
||||
* @param keyname
|
||||
* 要修改的参数名
|
||||
* @param content
|
||||
@@ -145,7 +81,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -213,7 +149,7 @@ public class ReadTxt {
|
||||
* 读取txt配置,返回map集合(文件格式:key=value,换行分隔)
|
||||
*
|
||||
* @param path
|
||||
* 文件地址(默认D:\\开头)
|
||||
* 文件地址(默认D:\\scbox_settings开头)
|
||||
* @return hashmap
|
||||
*/
|
||||
public static HashMap<String, String> readSetting(ServletContext servletContext, String path) {
|
||||
@@ -222,7 +158,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -268,7 +204,7 @@ public class ReadTxt {
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* 文件地址(默认D:\\开头)
|
||||
* 文件地址(默认D:\\scbox_settings开头)
|
||||
*
|
||||
* @param t 只取以此字符开头的,不限制填null
|
||||
* @param st 从以此字符开头的行开始读取,不限制填null
|
||||
@@ -284,7 +220,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -389,7 +325,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -458,7 +394,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -528,7 +464,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -615,7 +551,7 @@ public class ReadTxt {
|
||||
|
||||
if (servletContext == null) {
|
||||
if(path.indexOf(":") <= 0&&path.indexOf("/") <0)
|
||||
path = "D:\\" + path;
|
||||
path = "D:\\scbox_settings\\" + path;
|
||||
} else {
|
||||
path = servletContext.getRealPath(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user