package com.vci.client.fm;
|
|
import java.util.ArrayList;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Set;
|
|
import com.vci.client.fm.util.RandomUtil;
|
import com.vci.client.fm.util.TransformUtil;
|
import com.vci.corba.common.VCIError;
|
/**
|
* 文件存储路径相关业务类
|
* @author liwei
|
*
|
*/
|
public class FileCabinetPath {
|
|
/**
|
* 获取服务器端文件存储路径
|
* @return
|
*/
|
public static String getRandomServerSaveFilePath() throws VCIError{
|
try {
|
List<String> serverFileSaveCabinetPaths = null;
|
serverFileSaveCabinetPaths = getFileSavePath();
|
return serverFileSaveCabinetPaths.get(0);
|
} catch (VCIError e) {
|
throw new VCIError(String.valueOf(e.code), e.messages);
|
}
|
}
|
|
|
public static List<String> getFileSavePath() throws VCIError{
|
List<String> rs = null;
|
rs = new ArrayList<String>();
|
String firstPath = null;
|
String secondPath = null;
|
String te = null;
|
String ys2s = null;
|
Set<Integer> hs = RandomUtil.getRandom(25600, 1);
|
Iterator<Integer> it = hs.iterator();
|
while (it.hasNext()) {
|
int randomNum = it.next();
|
int ys = randomNum % 255;
|
String ys16 = TransformUtil.sl(16, ys);
|
if (ys16.length() <= 1) {
|
te = "0" + ys16;
|
} else {
|
te = ys16;
|
}
|
firstPath = te;
|
int ys2 = randomNum % 100;
|
if (ys2 <= 9) {
|
ys2s = "0" + ys2;
|
} else {
|
ys2s = ys2 + "";
|
}
|
secondPath = ys2s;
|
String mzPath = "/" + firstPath + "/" + secondPath;
|
rs.add(mzPath);
|
}
|
|
return rs;
|
|
}
|
|
}
|