锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲中文字幕精品有坂深雪,亚洲a级在线观看,亚洲av日韩av激情亚洲http://m.tkk7.com/zhyiwww/category/12118.htmlzhyiwwwzh-cnWed, 31 Oct 2007 11:54:04 GMTWed, 31 Oct 2007 11:54:04 GMT60瀹炵幇鍜?jdk\bin\native2ascii.exe 鍚屾牱鐨勫姛鑳?杞澆)http://m.tkk7.com/zhyiwww/archive/2006/07/12/57780.htmlzhyiwwwzhyiwwwWed, 12 Jul 2006 04:40:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/07/12/57780.htmlhttp://m.tkk7.com/zhyiwww/comments/57780.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/07/12/57780.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/57780.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/57780.html闃呰鍏ㄦ枃

zhyiwww 2006-07-12 12:40 鍙戣〃璇勮
]]>
[26] Getting the Size of the Java Memory Heaphttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52437.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 05:10:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52437.htmlhttp://m.tkk7.com/zhyiwww/comments/52437.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52437.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52437.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52437.html聽聽聽 聽聽聽 聽聽聽 聽聽聽
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽
// Get current size of heap in bytes
聽聽聽 long heapSize = Runtime.getRuntime().totalMemory();
聽聽聽
聽聽聽 // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
聽聽聽 // Any attempt will result in an OutOfMemoryException.
聽聽聽 long heapMaxSize = Runtime.getRuntime().maxMemory();
聽聽聽
聽聽聽 // Get amount of free memory within the heap in bytes. This size will increase
聽聽聽 // after garbage collection and decrease as new objects are created.
聽聽聽 long heapFreeSize = Runtime.getRuntime().freeMemory();
聽聽聽 聽聽聽 聽聽聽 聽聽聽
聽聽聽 聽聽聽 聽聽聽 聽聽聽


zhyiwww 2006-06-13 13:10 鍙戣〃璇勮
]]>
[25] Computing Elapsed Timehttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52435.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 05:07:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52435.htmlhttp://m.tkk7.com/zhyiwww/comments/52435.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52435.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52435.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52435.html 聽聽聽 // Get current time
聽聽聽 long start = System.currentTimeMillis();
聽聽聽
聽聽聽 // Do something ...
聽聽聽
聽聽聽 // Get elapsed time in milliseconds
聽聽聽 long elapsedTimeMillis = System.currentTimeMillis()-start;
聽聽聽
聽聽聽 // Get elapsed time in seconds
聽聽聽 float elapsedTimeSec = elapsedTimeMillis/1000F;
聽聽聽
聽聽聽 // Get elapsed time in minutes
聽聽聽 float elapsedTimeMin = elapsedTimeMillis/(60*1000F);
聽聽聽
聽聽聽 // Get elapsed time in hours
聽聽聽 float elapsedTimeHour = elapsedTimeMillis/(60*60*1000F);
聽聽聽
聽聽聽 // Get elapsed time in days
聽聽聽 float elapsedTimeDay = elapsedTimeMillis/(24*60*60*1000F);


zhyiwww 2006-06-13 13:07 鍙戣〃璇勮
]]>
[21] Serializing an Objecthttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52413.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:09:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52413.htmlhttp://m.tkk7.com/zhyiwww/comments/52413.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52413.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52413.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52413.htmlThe object to be serialized must implement java.io.Serializable. This example serializes a javax.swing.JButton object.

See also e45 Deserializing an Object.

				
						Object object = new javax.swing.JButton("push me");
    
    try {
        // Serialize to a file
        ObjectOutput out = new ObjectOutputStream(new FileOutputStream("filename.ser"));
        out.writeObject(object);
        out.close();
    
        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
        out = new ObjectOutputStream(bos) ;
        out.writeObject(object);
        out.close();
    
        // Get the bytes of the serialized object
        byte[] buf = bos.toByteArray();
    } catch (IOException e) {
    }
				
		


zhyiwww 2006-06-13 12:09 鍙戣〃璇勮
]]>
[21] Writing UTF-8 Encoded Datahttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52412.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:08:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52412.htmlhttp://m.tkk7.com/zhyiwww/comments/52412.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52412.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52412.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52412.html 聽聽聽 try {
聽聽聽聽聽聽聽 Writer out = new BufferedWriter(new OutputStreamWriter(
聽聽聽聽聽聽聽聽聽聽聽 new FileOutputStream("outfilename"), "UTF8"));
聽聽聽聽聽聽聽 out.write(aString);
聽聽聽聽聽聽聽 out.close();
聽聽聽 } catch (UnsupportedEncodingException e) {
聽聽聽 } catch (IOException e) {
聽聽聽 }


zhyiwww 2006-06-13 12:08 鍙戣〃璇勮
]]>
[20] Reading UTF-8 Encoded Datahttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52411.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:07:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52411.htmlhttp://m.tkk7.com/zhyiwww/comments/52411.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52411.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52411.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52411.html 聽聽聽 try {
聽聽聽聽聽聽聽 BufferedReader in = new BufferedReader(
聽聽聽聽聽聽聽聽聽聽聽 new InputStreamReader(new FileInputStream("infilename"), "UTF8"));
聽聽聽聽聽聽聽 String str = in.readLine();
聽聽聽 } catch (UnsupportedEncodingException e) {
聽聽聽 } catch (IOException e) {
聽聽聽 }


zhyiwww 2006-06-13 12:07 鍙戣〃璇勮
]]>
[19] Using a Random Access Filehttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52410.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:06:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52410.htmlhttp://m.tkk7.com/zhyiwww/comments/52410.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52410.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52410.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52410.html聽聽聽 try {
聽聽聽聽聽聽聽 File f = new File("filename");
聽聽聽聽聽聽聽 RandomAccessFile raf = new RandomAccessFile(f, "rw");
聽聽聽
聽聽聽聽聽聽聽 // Read a character
聽聽聽聽聽聽聽 char ch = raf.readChar();
聽聽聽
聽聽聽聽聽聽聽 // Seek to end of file
聽聽聽聽聽聽聽 raf.seek(f.length());
聽聽聽
聽聽聽聽聽聽聽 // Append to the end
聽聽聽聽聽聽聽 raf.writeChars("aString");
聽聽聽聽聽聽聽 raf.close();
聽聽聽 } catch (IOException e) {
聽聽聽 }


zhyiwww 2006-06-13 12:06 鍙戣〃璇勮
]]>
[17] Reading a File into a Byte Arrayhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52408.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:05:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52408.htmlhttp://m.tkk7.com/zhyiwww/comments/52408.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52408.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52408.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52408.htmlThis example implements a method that reads the entire contents of a file into a byte array.


聽// Returns the contents of the file in a byte array.

				
						
								    public static byte[] getBytesFromFile(File file) throws IOException {
InputStream is = new FileInputStream(file);

// Get the size of the file
long length = file.length();

// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE) {
// File is too large
}

// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
}

// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "+file.getName());
}

// Close the input stream and return bytes
is.close();
return bytes;
}



zhyiwww 2006-06-13 12:05 鍙戣〃璇勮
]]>
[14] Reading Text from Standard Inputhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52406.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:03:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52406.htmlhttp://m.tkk7.com/zhyiwww/comments/52406.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52406.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52406.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52406.html聽聽聽 try {
聽聽聽聽聽聽聽 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
聽聽聽聽聽聽聽 String str = "";
聽聽聽聽聽聽聽 while (str != null) {
聽聽聽聽聽聽聽聽聽聽聽 System.out.print("> prompt ");
聽聽聽聽聽聽聽聽聽聽聽 str = in.readLine();
聽聽聽聽聽聽聽聽聽聽聽 process(str);
聽聽聽聽聽聽聽 }
聽聽聽 } catch (IOException e) {
聽聽聽 }


zhyiwww 2006-06-13 12:03 鍙戣〃璇勮
]]>
[12] Getting and Setting the Modification Time of a File or Directoryhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52403.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:02:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52403.htmlhttp://m.tkk7.com/zhyiwww/comments/52403.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52403.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52403.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52403.htmlThis example gets the last modified time of a file or directory and then sets it to the current time.
				
						 File file = new File("filename");
    
    // Get the last modified time
    long modifiedTime = file.lastModified();
    // 0L is returned if the file does not exist
    
    // Set the last modified time
    long newModifiedTime = System.currentTimeMillis();
    boolean success = file.setLastModified(newModifiedTime);
    if (!success) {
        // operation failed.
    }
				
		


zhyiwww 2006-06-13 12:02 鍙戣〃璇勮
]]>
[11] Forcing Updates to a File to the Diskhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52402.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:01:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52402.htmlhttp://m.tkk7.com/zhyiwww/comments/52402.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52402.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52402.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52402.htmlIn some applications, such as transaction processing, it is necessary to ensure that an update has been made to the disk. FileDescriptor.sync() blocks until all changes to a file are written to disk.
				
						    try {
        // Open or create the output file
        FileOutputStream os = new FileOutputStream("outfilename");
        FileDescriptor fd = os.getFD();
    
        // Write some data to the stream
        byte[] data = new byte[]{(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE};
        os.write(data);
    
        // Flush the data from the streams and writers into system buffers.
        // The data may or may not be written to disk.
        os.flush();
    
        // Block until the system buffers have been written to disk.
        // After this method returns, the data is guaranteed to have
        // been written to disk.
        fd.sync();
    } catch (IOException e) {
    }
				
		


zhyiwww 2006-06-13 12:01 鍙戣〃璇勮
]]>
[10] Creating a Temporary Filehttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52401.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 04:00:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52401.htmlhttp://m.tkk7.com/zhyiwww/comments/52401.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52401.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52401.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52401.html聽聽聽 try {
聽聽聽聽聽聽聽 // Create temp file.
聽聽聽聽聽聽聽 File temp = File.createTempFile("pattern", ".suffix");
聽聽聽
聽聽聽聽聽聽聽 // Delete temp file when program exits.
聽聽聽聽聽聽聽 temp.deleteOnExit();
聽聽聽
聽聽聽聽聽聽聽 // Write to temp file
聽聽聽聽聽聽聽 BufferedWriter out = new BufferedWriter(new FileWriter(temp));
聽聽聽聽聽聽聽 out.write("aString");
聽聽聽聽聽聽聽 out.close();
聽聽聽 } catch (IOException e) {
聽聽聽 }


zhyiwww 2006-06-13 12:00 鍙戣〃璇勮
]]>
[9] Copying One File to Anotherhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52400.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:58:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52400.htmlhttp://m.tkk7.com/zhyiwww/comments/52400.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52400.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52400.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52400.htmlThis example uses file streams to copy the contents of one file to another file. See e172 Copying One File to Another for an example that uses file channels.
				
						  // Copies src file to dst file.
    // If the dst file does not exist, it is created
    void copy(File src, File dst) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);
    
        // Transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    }
				
		


zhyiwww 2006-06-13 11:58 鍙戣〃璇勮
]]>
[8] Determining If Two Filename Paths Refer to the Same Filehttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52399.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:56:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52399.htmlhttp://m.tkk7.com/zhyiwww/comments/52399.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52399.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52399.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52399.htmlA filename path may include redundant names such as `.' or `..' or symbolic links (on UNIX platforms). File.getCanonicalFile() converts a filename path to a unique canonical form suitable for comparisons.
				
						    File file1 = new File("./filename");
    File file2 = new File("filename");
    
    // Filename paths are not equal
    boolean b = file1.equals(file2);      // false
    
    // Normalize the paths
    try {
        file1 = file1.getCanonicalFile(); // c:\almanac1.4\filename
        file2 = file2.getCanonicalFile(); // c:\almanac1.4\filename
    } catch (IOException e) {
    }
    
    // Filename paths are now equal
    b = file1.equals(file2);              // true
				
		


zhyiwww 2006-06-13 11:56 鍙戣〃璇勮
]]>
[7] Getting an Absolute Filename Path from a Relative Filename Pathhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52398.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:55:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52398.htmlhttp://m.tkk7.com/zhyiwww/comments/52398.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52398.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52398.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52398.html聽聽聽 File file = new File("filename.txt");
聽聽聽 file = file.getAbsoluteFile();聽 // c:\temp\filename.txt
聽聽聽
聽聽聽 file = new File("dir"+File.separatorChar+"filename.txt");
聽聽聽 file = file.getAbsoluteFile();聽 // c:\temp\dir\filename.txt
聽聽聽
聽聽聽 file = new File(".."+File.separatorChar+"filename.txt");
聽聽聽 file = file.getAbsoluteFile();聽 // c:\temp\..\filename.txt
聽聽聽
聽聽聽 // Note that filename.txt does not need to exist


zhyiwww 2006-06-13 11:55 鍙戣〃璇勮
]]>
[6] Converting Between a Filename Path and a URLhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52396.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:53:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52396.htmlhttp://m.tkk7.com/zhyiwww/comments/52396.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52396.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52396.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52396.html聽聽聽 // Create a file object
聽聽聽 File file = new File("filename");
聽聽聽
聽聽聽 // Convert the file object to a URL
聽聽聽 URL url = null;
聽聽聽 try {
聽聽聽聽聽聽聽 // The file need not exist. It is made into an absolute path
聽聽聽聽聽聽聽 // by prefixing the current working directory
聽聽聽聽聽聽聽 url = file.toURL();聽聽聽聽聽聽聽聽聽 // file:/d:/almanac1.4/java.io/filename
聽聽聽 } catch (MalformedURLException e) {
聽聽聽 }
聽聽聽
聽聽聽 // Convert the URL to a file object
聽聽聽 file = new File(url.getFile());聽 // d:/almanac1.4/java.io/filename
聽聽聽
聽聽聽 // Read the file contents using the URL
聽聽聽 try {
聽聽聽聽聽聽聽 // Open an input stream
聽聽聽聽聽聽聽 InputStream is = url.openStream();
聽聽聽
聽聽聽聽聽聽聽 // Read from is
聽聽聽
聽聽聽聽聽聽聽 is.close();
聽聽聽 } catch (IOException e) {
聽聽聽聽聽聽聽 // Could not open the file
聽聽聽 }


zhyiwww 2006-06-13 11:53 鍙戣〃璇勮
]]>
[5] Constructing a Filename Pathhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52395.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:52:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52395.htmlhttp://m.tkk7.com/zhyiwww/comments/52395.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52395.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52395.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52395.htmlA File object is used to represent a filename. Creating the File object has no effect on the file system; the filename need not exist nor is it created.

On Windows, this example creates the path\a\b. On Unix, the path would be /a/b.

				
						    String path = File.separator + "a" + File.separator + "b";
				
		


zhyiwww 2006-06-13 11:52 鍙戣〃璇勮
]]>
[4] Traversing the Files and Directories Under a Directoryhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52394.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:49:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52394.htmlhttp://m.tkk7.com/zhyiwww/comments/52394.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52394.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52394.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52394.html This example implements methods that recursively visits all files and directories under a directory.
				
						// Process all files and directories under dir
    public static void visitAllDirsAndFiles(File dir) {
        process(dir);
    
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i=0; i<children.length; i++) {
                visitAllDirsAndFiles(new File(dir, children[i]));
            }
        }
    }
    
    // Process only directories under dir
    public static void visitAllDirs(File dir) {
        if (dir.isDirectory()) {
            process(dir);
    
            String[] children = dir.list();
            for (int i=0; i<children.length; i++) {
                visitAllDirs(new File(dir, children[i]));
            }
        }
    }
    
    // Process only files under dir
    public static void visitAllFiles(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i=0; i<children.length; i++) {
                visitAllFiles(new File(dir, children[i]));
            }
        } else {
            process(dir);
        }
    }
				
		


zhyiwww 2006-06-13 11:49 鍙戣〃璇勮
]]>
[3] Listing the Files or Subdirectories in a Directoryhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52392.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:45:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52392.htmlhttp://m.tkk7.com/zhyiwww/comments/52392.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52392.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52392.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52392.html This example lists the files and subdirectories in a directory. To list all descendant files and subdirectories under a directory, see e33 Traversing the Files and Directories Under a Directory .
				
						File dir = new File("directoryName");
    
    String[] children = dir.list();
    if (children == null) {
        // Either dir does not exist or is not a directory
    } else {
        for (int i=0; i<children.length; i++) {
            // Get filename of file or directory
            String filename = children[i];
        }
    }
    
    // It is also possible to filter the list of returned files.
    // This example does not return any files that start with `.'.
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return !name.startsWith(".");
        }
    };
    children = dir.list(filter);
    
    
    // The list of files can also be retrieved as File objects
    File[] files = dir.listFiles();
    
    // This filter only returns directories
    FileFilter fileFilter = new FileFilter() {
        public boolean accept(File file) {
            return file.isDirectory();
        }
    };
    files = dir.listFiles(fileFilter);
				
		


zhyiwww 2006-06-13 11:45 鍙戣〃璇勮
]]>
[2] Getting the Current Working Directoryhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52391.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:43:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52391.htmlhttp://m.tkk7.com/zhyiwww/comments/52391.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52391.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52391.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52391.html

The working directory is the location in the file system from where the java command was invoked.

				
						
								
										
										String curDir = System.getProperty("user.dir");
						
				
		


zhyiwww 2006-06-13 11:43 鍙戣〃璇勮
]]>
[1] Copying a Directoryhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52389.htmlzhyiwwwzhyiwwwTue, 13 Jun 2006 03:37:00 GMThttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52389.htmlhttp://m.tkk7.com/zhyiwww/comments/52389.htmlhttp://m.tkk7.com/zhyiwww/archive/2006/06/13/52389.html#Feedback0http://m.tkk7.com/zhyiwww/comments/commentRss/52389.htmlhttp://m.tkk7.com/zhyiwww/services/trackbacks/52389.html 聽聽聽 // Copies all files under srcDir to dstDir.
聽聽聽 // If dstDir does not exist, it will be created.
聽聽聽 public void copyDirectory(File srcDir, File dstDir) throws IOException {
聽聽聽聽聽聽聽 if (srcDir.isDirectory()) {
聽聽聽聽聽聽聽聽聽聽聽 if (!dstDir.exists()) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 dstDir.mkdir();
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽
聽聽聽聽聽聽聽聽聽聽聽 String[] children = srcDir.list();
聽聽聽聽聽聽聽聽聽聽聽 for (int i=0; i<children.length; i++) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 copyDirectory(new File(srcDir, children[i]),
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 new File(dstDir, children[i]));
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 } else {
聽聽聽聽聽聽聽聽聽聽聽 // This method is implemented in
e1071 Copying a File
聽聽聽聽聽聽聽聽聽聽聽 copyFile(srcDir, dstDir);
聽聽聽聽聽聽聽 }
聽聽聽 }



zhyiwww 2006-06-13 11:37 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲日韩乱码久久久久久| 久久久无码精品亚洲日韩按摩| 91精品视频在线免费观看| 日韩一卡2卡3卡4卡新区亚洲| 亚洲高清在线视频| 亚洲av永久无码嘿嘿嘿| 国产精品永久免费10000| 亚洲第一成年人网站| 一级毛片免费全部播放| 日本免费xxxx| 国产亚洲精品岁国产微拍精品| 国产久爱免费精品视频| 免费羞羞视频网站| 亚洲日韩乱码中文无码蜜桃| AV大片在线无码永久免费| 国产亚洲福利在线视频| 免费看国产曰批40分钟| 国产精品综合专区中文字幕免费播放| 国产精品xxxx国产喷水亚洲国产精品无码久久一区| 免费看黄网站在线看| 国产亚洲精品一品区99热| 2022久久国产精品免费热麻豆| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 精品国产人成亚洲区| 免费国产成人午夜在线观看| 亚洲精品偷拍视频免费观看| 国产成人无码区免费内射一片色欲| 91在线亚洲精品专区| 国产精品极品美女免费观看| 插鸡网站在线播放免费观看| 亚洲国产成人乱码精品女人久久久不卡 | 日韩特黄特色大片免费视频| 亚洲日本国产精华液| 精品久久洲久久久久护士免费| av片在线观看永久免费| 亚洲日产2021三区在线| 亚洲免费日韩无码系列| 波多野结衣中文字幕免费视频 | 亚洲成a人片在线观看中文动漫| 男人的好看免费观看在线视频| 亚洲成年人电影网站|