package com.o2o.util; public class PathUtil { //获取当前系统是以“/”还是“\”为路径 private static String seperator=System.getProperty("file.separator"); public static String getImgBasePath() { //获取操作系统 String os=System.getProperty("os.name"); String basePath=""; //判断是否是Windows系统 if(os.toLowerCase().startsWith("win")) { basePath="D:/project/o2o/image"; }else { basePath="/home/o2o/image"; } basePath=basePath.replace("/", seperator); return basePath; } //根据shopId创建图片相对路径 public static String getShopImagePath(long shopId) { String imagePath="/upload/item/shop/"+shopId+"/"; return imagePath.replace("/", seperator); } }
简单的路径获取工具类
猜你喜欢
转载自www.cnblogs.com/cwz-/p/11211280.html
今日推荐
周排行