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

📄 u07fileoperation.java

📁 持久层hibernate技术使用的一个例子
💻 JAVA
字号:
/*
 * Created on 2005-1-4
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cn.hope.front.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.struts.upload.FormFile;

/**
 * @author zhaogang
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public final class U07FileOperation {
	public U07FileOperation() {
	}

	public void doUpload(FormFile file, String saveURI) throws Exception {
		InputStream stream = file.getInputStream();
		OutputStream bos = new FileOutputStream(saveURI);
		int bytesRead = 0;
		byte[] buffer = new byte[8192];
		while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
			bos.write(buffer, 0, bytesRead);

		}
		bos.close();
		stream.close();
	}

	public void mdir(String s) throws Exception {
		try {
			File dirname = new File(s);
			if (!dirname.exists()) {
				dirname.mkdir();
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception();
		}

	}

	public int del(String filepath) throws Exception {
		try {
			File fileName = new File(filepath);
			if (fileName.exists()) {
				fileName.delete();
			}
			return 1;
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
	}
	
	}

⌨️ 快捷键说明

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