日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

java web代码规范:

發(fā)布時(shí)間:2024/10/12 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java web代码规范: 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

每個(gè)類(lèi)前要有注釋,類(lèi)前的注釋格式是:

/**

*類(lèi)是干什么的

*@author ?編寫(xiě)該類(lèi)的作者

*/

類(lèi)中的每個(gè)方法前也要有注釋:

/**

*該方法是干什么的

*@param 該方法中傳入的參數(shù)

*@return

*/

/**
* 目錄服務(wù)類(lèi)
* @author X
*
*/
@Component("project.docm.catalog.CatalogService")
@SuppressWarnings("all")
public class CatalogService {
@Autowired
PlatParamItemService paramItemService;

/**
* 獲取根目錄
* @return
*/
private String getRootPath(){
return paramItemService.getParam("FILE_FOLDER").getEvalue();
}


private String getIndexPath(){
return paramItemService.getParam("INDEX_FOLDER").getEvalue();
}
/**
* 查詢(xún)目錄
* @param path
* @return
*/
public List getCatalogs(String path) throws Exception{
File file = new File(path);
List result = new ArrayList();
if(file.isDirectory()){
//根目錄
Map m = new HashMap();
m.put("id",UUID.randomUUID().toString());
m.put("name", file.getName());
m.put("len", file.list().length);
m.put("path", ZipUtils.gzip(file.getPath()));
m.put("size", file.length());
m.put("iconCls", "fa fa-laptop");
m.put("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(file.lastModified())));
m.put("children", eachCatalog(file));
result.add(m);
}else{
throw new Exception("不是一個(gè)目錄");
}
return result;
}

public List getFiles(File catalog){
List result = new ArrayList();
if(catalog.isDirectory() && catalog.exists()){
File[] files = catalog.listFiles();
for(File file : files){
if(file.isFile()){
Map m = new HashMap();
m.put("id",UUID.randomUUID().toString());
m.put("name", file.getName());
m.put("path", ZipUtils.gzip(file.getPath()));
m.put("size", file.length());
m.put("iconCls", "fa fa-laptop");
m.put("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(file.lastModified())));
result.add(m);
}
}
}
return result;
}

public List eachCatalog(File path){
if(path.isDirectory()){
File[] files = path.listFiles();
List dirs = new ArrayList();
for(File file : files){
if(file.isDirectory()){
Map m = new HashMap();
m.put("id",UUID.randomUUID().toString());
m.put("path", ZipUtils.gzip(file.getPath()));
m.put("name", file.getName());
m.put("len", file.list().length);
m.put("size", file.length());
m.put("iconCls", "fa fa-folder");
m.put("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(file.lastModified())));
m.put("children", eachCatalog(file));
dirs.add(m);
}
}
return dirs;
}
return null;
}

//新增目錄
@Transactional
public Object saveCatalogs(File file){
if(!file.exists()){
if(file.mkdir()){
Map m = new HashMap();
m.put("id",UUID.randomUUID().toString());
m.put("name", file.getName());
m.put("len", file.list().length);
m.put("path", ZipUtils.gzip(file.getPath()));
m.put("size", file.length());
m.put("iconCls", "fa fa-folder");
m.put("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(file.lastModified())));
m.put("children", eachCatalog(file));
return m;
}
}
return false;
}
//刪除目錄
public boolean deleteCatalogs(File file) {
if(file.exists() && file.isDirectory()){
if(file.delete()){
//刪除索引
try {
IndexHelper.deleteIndex(file, getIndexPath(), getRootPath());
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
}
return false;
}
/**
* 刪除文件
* @param file
* @return
*/
public boolean deleteFile(File file) {
if(file.exists()){
return file.delete();
}
return false;
}
}

轉(zhuǎn)載于:https://www.cnblogs.com/zhangshitong/p/4974460.html

總結(jié)

以上是生活随笔為你收集整理的java web代码规范:的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。