public class complie {

在松溪等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站設計、成都網(wǎng)站建設 網(wǎng)站設計制作定制網(wǎng)站制作,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,高端網(wǎng)站設計,成都全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站建設,松溪網(wǎng)站建設費用合理。
int i,j;
public complie(int i,int j)//構建一個復數(shù)類
{
this.i=i;
this.j=j;
}
complie add(complie c)//復數(shù)加法
{
int l,k;
l=c.i+i;
k=c.j+j;
return (new complie(l,k));
}
complie cut(complie c)//復數(shù)減法
{
int l,k;
l=i-c.i;
k=j-c.j;
return (new complie(l,k));
}
void ToString()//將復數(shù)輸出
{
System.out.println("復數(shù)為:"+i+"+"+j+"i");
}
public static void main(String[] args)
{
complie a=new complie(4,5);
complie b=new complie(2,3);
System.out.println("構造的復數(shù)類為:");
a.ToString();
b.ToString();
System.out.println("運算復數(shù)a+b=:");
a.add(b).ToString();
System.out.println("運算復數(shù)a-b=:");
a.cut(b).ToString();
}
}
這是一個抽象類,根據(jù)不同的操作系統(tǒng)會有不同的實現(xiàn)。典型的windows和unix操作系統(tǒng)對文件的管理就不一樣。
getFileSystem()是一個本地方法,看不到源代碼。
FileSystem類本來就不是提供給程序員使用的。
反編譯后的源代碼如下:
package java.io;
// Referenced classes of package java.io:
// IOException, File
abstract class FileSystem
{
FileSystem()
{
}
public static native FileSystem getFileSystem();
public abstract char getSeparator();
public abstract char getPathSeparator();
public abstract String normalize(String s);
public abstract int prefixLength(String s);
public abstract String resolve(String s, String s1);
public abstract String getDefaultParent();
public abstract String fromURIPath(String s);
public abstract boolean isAbsolute(File file);
public abstract String resolve(File file);
public abstract String canonicalize(String s)
throws IOException;
public abstract int getBooleanAttributes(File file);
public abstract boolean checkAccess(File file, int i);
public abstract boolean setPermission(File file, int i, boolean flag, boolean flag1);
public abstract long getLastModifiedTime(File file);
public abstract long getLength(File file);
public abstract boolean createFileExclusively(String s)
throws IOException;
public abstract boolean delete(File file);
public abstract String[] list(File file);
public abstract boolean createDirectory(File file);
public abstract boolean rename(File file, File file1);
public abstract boolean setLastModifiedTime(File file, long l);
public abstract boolean setReadOnly(File file);
public abstract File[] listRoots();
public abstract long getSpace(File file, int i);
public abstract int compare(File file, File file1);
public abstract int hashCode(File file);
private static boolean getBooleanProperty(String s, boolean flag)
{
String s1 = System.getProperty(s);
if(s1 == null)
return flag;
return s1.equalsIgnoreCase("true");
}
public static final int BA_EXISTS = 1;
public static final int BA_REGULAR = 2;
public static final int BA_DIRECTORY = 4;
public static final int BA_HIDDEN = 8;
public static final int ACCESS_READ = 4;
public static final int ACCESS_WRITE = 2;
public static final int ACCESS_EXECUTE = 1;
public static final int SPACE_TOTAL = 0;
public static final int SPACE_FREE = 1;
public static final int SPACE_USABLE = 2;
static boolean useCanonCaches;
static boolean useCanonPrefixCache;
static
{
useCanonCaches = true;
useCanonPrefixCache = true;
useCanonCaches = getBooleanProperty("sun.io.useCanonCaches", useCanonCaches);
useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache", useCanonPrefixCache);
}
}
這是別人寫好的
package sunnykid.file;
import java.io.*;
import sunnykid.text.SunnykidNumber;
/**
* p標題: JAVA文件操作工具類/p
* br
* p描述: 陽光軟體工作室常用工具包/p
* br
* p版權: 版權所有 (c) 2007/p
* br
* p組織: 陽光軟體工作室/p
*
* @author 鐘曉籟
* @version V1.0
*/
public class FileOperator {
/**
* 不帶參數(shù)的構造函數(shù)
*/
public FileOperator() {
super();
}
/**
* 刪除指定的文件
* @param filepath String 待刪除的文件路徑及名稱
* @throws IOException
*/
public void delete(String filepath) throws IOException {
Runtime rt = Runtime.getRuntime();
rt.exec("cmd /c del " + filepath);
}
/**
* 將字符串寫入文件
* @param content String 待寫入的字符串內(nèi)容
* @param filepath String 待寫入的文件路徑及名稱
* @throws IOException
*/
public void write(String content, String filepath) throws IOException {
File file = new File(filepath);
FileWriter fw = new FileWriter(file);
fw.write(content);
fw.close();
}
/**
* 讀取文件中的內(nèi)容
* @param filepath String 待讀取的文件路徑及名稱
* @return String 返回從文件中讀取的字符串內(nèi)容
* @throws IOException
*/
public String read(String filepath) throws IOException {
int text = 0;
File file = new File(filepath);
FileReader fr = new FileReader(file);
int len = (int) file.length();
char[] buffer = new char[len];
while (fr.ready()) {
text = text + fr.read(buffer, text, len - text);
}
fr.close();
String content = new String(buffer, 0, text);
return content;
}
/**
* 判斷一個文件是否存在
* @param filepath String 待判斷的文件路徑及名稱
* @return boolean 返回文件是否存在結果
*/
public boolean isExist(String filepath) {
File file = new File(filepath);
if (file.exists()) {
return true;
} else {
return false;
}
}
/**
* 重命名文件或目錄
* @param oldname String 重命名前的文件或目錄名稱
* @param newname String 重命名后的文件或目錄名稱
* @return boolean 返回操作是否成功結果
*/
public boolean rename(String oldname, String newname) {
File oldfile = new File(oldname);
File newfile = new File(newname);
boolean success = oldfile.renameTo(newfile);
return success;
}
/**
* 剪切指定文件至指定的目錄
* @param from String 源文件的路徑及名稱
* @param to String 目標路徑及名稱
*/
public void move(String from, String to) {
File oldfile = new File(from);
File newfile = new File(to);
oldfile.renameTo(newfile);
}
/**
* 拷貝指定文件至指定的目錄
* @param from String 源文件的路徑及名稱
* @param to String 目標路徑及名稱
* @throws IOException
*/
public void copy(String from, String to) throws IOException {
int BUFF_SIZE = 100000;
byte[] buffer = new byte[BUFF_SIZE];
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(from);
out = new FileOutputStream(to);
while (true) {
synchronized (buffer) {
int amountRead = in.read(buffer);
if (amountRead 0) {
break;
}
out.write(buffer, 0, amountRead);
}
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
/**
* 獲取文件擴展名
* @param filename String 需要獲取大小的文件之完整路徑
* @return String 返回文件擴展名
*/
public String getExtension(String filename) {
String defExt = null;
if ((filename != null) (filename.length() 0)) {
int i = filename.lastIndexOf('.');
if ((i 0) (i (filename.length() - 1))) {
defExt = filename.substring(i + 1);
}
}
return defExt;
}
/**
* 獲取文件字節(jié)數(shù)
* @param filename String 需要獲取大小的文件之完整路徑
* @return long 返回文件大小字節(jié)數(shù)
*/
public long fileSize(String filename) {
long size = 0L;
File file = new File(filename);
if (this.isExist(filename) == true) {
size = file.length();
}
return size;
}
/**
* 獲取標準單位之文件大小
* @param bytesize long 需要轉(zhuǎn)換為標準單位的文件之字節(jié)數(shù)
* @return String 返回標準單位之文件大小
*/
public String switchSize(long bytesize) {
String size = "";
SunnykidNumber sn=new SunnykidNumber();
float number = 0.0f;
if (bytesize = 0) {
size = "0Bytes";
} else if (bytesize 1024) {
size = String.valueOf(size) + "Bytes";
} else if (bytesize 1048576) {
number = (float) bytesize / 1024;
size = sn.parseCurrency(number) + "KB";
} else if (bytesize 1073741824) {
number = (float) bytesize / 1024 / 1024;
size = sn.parseCurrency(number) + "MB";
} else if (bytesize 1099511627776L) {
number = (float) bytesize / 1024 / 1024 / 1024;
size = sn.parseCurrency(number) + "GB";
}
return size;
}
}
====================
package sunnykid.text;
import java.text.*;
/**
* p標題: 用於操作數(shù)字的類/p
* br
* p描述: 陽光軟體工作室常用工具包/p
* br
* p版權: 版權所有 (c) 2007/p
* br
* p組織: 陽光軟體工作室/p
*
* @author 鐘曉籟
* @version V1.0
*/
public class SunnykidNumber {
/**
* 不帶參數(shù)的構造函數(shù)
*/
public SunnykidNumber() {
super();
}
/**
* 將數(shù)字格式化成貨幣樣式
* @param unfmt_dbl double 未經(jīng)格式化的數(shù)字
* @return String 返回按照貨幣樣式格式化后的字符串
*/
public String getCurrency(double unfmt_dbl) { //雙精度數(shù)轉(zhuǎn)化成貨幣類型兩位小數(shù)
NumberFormat nf = NumberFormat.getCurrencyInstance(); //按照貨幣類型格式化數(shù)字
String fmted_str = nf.format(unfmt_dbl);
return fmted_str;
}
/**
* 按照貨幣類型格式化數(shù)字
* @param unfmt_dbl double 未經(jīng)格式化的數(shù)字
* @return String 返回按照貨幣類型格式化后的字符串
*/
public String parseCurrency(double unfmt_dbl) { //雙精度數(shù)轉(zhuǎn)化成貨幣類型兩位小數(shù)的字符串
DecimalFormat df = new DecimalFormat("#.00"); //按照貨幣類型格式化數(shù)字
String fmted_str = df.format(unfmt_dbl);
return fmted_str;
}
/**
* 雙精度小數(shù)轉(zhuǎn)化成百分數(shù)
* @param unfmt_dbl double 未經(jīng)格式化的數(shù)字
* @return String 返回按照百分比樣式格式化后的字符串
*/
public String parsePercect(double unfmt_dbl) { //雙精度小數(shù)轉(zhuǎn)化成百分數(shù)
NumberFormat nf = NumberFormat.getPercentInstance(); //按照百分比格式化數(shù)字
// nf.setMinimumIntegerDigits(integ);// 設置數(shù)的整數(shù)部分所允許的最大位數(shù)
// nf.setMaximumFractionDigits(fract);// 設置數(shù)的小數(shù)部分所允許的最大位數(shù)
String fmted_str = nf.format(unfmt_dbl);
return fmted_str;
}
/**
* 雙精度小數(shù)四舍五入為整數(shù)
* @param unfmt_dbl double 未經(jīng)轉(zhuǎn)化的小數(shù)
* @return int 小數(shù)四舍后得到的整數(shù)
*/
public int roundNumber(double unfmt_dbl) {
String temp_str = String.valueOf(unfmt_dbl); //將小數(shù)轉(zhuǎn)化為字符串
if (temp_str.indexOf(".") = 0) {
}
int indexOfDot = temp_str.indexOf("."); //獲取小數(shù)點位置
int temp_int = Integer.parseInt(temp_str.substring(indexOfDot + 1,
indexOfDot + 2));
if (temp_int 5) { //判斷小數(shù)點后一位的數(shù)字是否大於5
return Integer.parseInt(temp_str.substring(0, indexOfDot)); //四舍
} else {
return Integer.parseInt(temp_str.substring(0, indexOfDot)) + 1; //五入
}
}
}
分享名稱:文件管理源代碼java,文件管理軟件開源
轉(zhuǎn)載注明:http://chinadenli.net/article35/dsejepi.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導航、移動網(wǎng)站建設、搜索引擎優(yōu)化、品牌網(wǎng)站設計、軟件開發(fā)、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)