⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemfile.java

📁 EasyJF官网(www.easyjf.com)全站系统源码使用说明 全站源码是EasyJF开源团队站务组及核心成员共同开发及维护的系统
💻 JAVA
字号:
package com.easyjf.news.business;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.DecimalFormat;
import java.util.Date;
import com.easyjf.web.Globals;
public class SystemFile {
private static final DecimalFormat cf=new DecimalFormat(".00");
private File file;
private String path;
private int types;
private String content;
public SystemFile()
{
	
}
public SystemFile(File file)
{
	this.file=file;
}
public String getPic()
{
		 if(file.isDirectory())return "folder.gif";
		 else return "page.gif";	
}
public Integer getChildNum()
   {
	   Integer num=null;	  
	   if(file.exists())
	   {
		   if(file.isDirectory())num=new Integer(file.list().length);
	   }
	   return num;
   }
public Date getModifyTime()
{
	return new Date(file.lastModified());
}
public String getName()
{
	return file.getName();
}
public String getPath()
{
	if(file!=null)
    return file.getAbsolutePath().substring(Globals.APP_BASE_DIR.length()-1);
	else return path;
}
public boolean delFile()
{
	boolean ret=false;		
	if(file.exists())ret=file.delete();
	return ret;
}
public boolean saveToFile()
{
	boolean ret=false;
	File f=this.file;
	if(this.types==1 && (!f.exists()))f.mkdirs();    		
	else if(!f.isDirectory())		
	{	
		try{
		if(!f.exists())f.createNewFile();	
		OutputStream o=new FileOutputStream(f);
		OutputStreamWriter out=new OutputStreamWriter(o,"utf-8");			
		out.write(this.content);
		out.close();
		}
		catch(Exception e)
		{				
		e.printStackTrace();	
		}			
	}
	return ret;
}
public String readFromFile()
{
	String  c="";
	File f=this.file;		
	if(f.isFile() && f.exists())
	{
		try{
		FileInputStream fin=new FileInputStream(f);
		byte[] b=new byte[fin.available()];
		fin.read(b);
		c=new String(b,"utf-8");
		fin.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}		
	return c;
}
public static String caculateByte(float size)
{
	float si=size/1024f;
	 String sizeInfo="";
	 if(si/1024>1)
	 {
		 sizeInfo=cf.format(si/1024f)+"MB";
	 }
	 else sizeInfo=cf.format(si)+"KB";
	 return sizeInfo;
}
public String getSize()
{
	float si=file.length()/1024f;
	 String sizeInfo="";
	 if(si/1024>1)
	 {
		 sizeInfo=cf.format(si/1024f)+"MB";
	 }
	 else sizeInfo=cf.format(si)+"KB";
	return sizeInfo;
}
public String getContent() {
	return content;
}
public void setContent(String content) {
	this.content = content;
}
public int getTypes() {
	return types;
}
public void setTypes(int types) {
	this.types = types;
}
public void setPath(String path) {
	this.path = path;
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -