Java tutorial
/* * Copyright (C) 2008 feilong * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.sunchenbin.store.feilong.core.io; import java.io.File; import javax.swing.filechooser.FileSystemView; import org.apache.commons.lang3.SystemUtils; /** * . * * @author feilong * @version 1.0.1 2011-3-22 ?11:45:57 * @since 1.0.1 * @see org.apache.commons.lang3.SystemUtils */ public final class SpecialFolder { /** Don't let anyone instantiate this class. */ private SpecialFolder() { //AssertionError?. ?????. ???. //see Effective Java 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); } /** * ?. * <ul> * <li>win7:C:\Users\VENUSD~1\AppData\Local\Temp\</li> * <li>win7:C:\Users\feilong\AppData\Local\Temp\</li> * </ul> * * @return ? * * @see org.apache.commons.lang3.SystemUtils#JAVA_IO_TMPDIR */ public static String getTemp() { return SystemUtils.JAVA_IO_TMPDIR; } /** * ?<br> * example:win7:C:\Users\venusdrogon\Desktop. * * <br> * ?? USERPROFILE<br> * return C:\Users\venusdrogon ? Desktop * * @return ?? * @see FileSystemView#getHomeDirectory() */ public static String getDesktop() { FileSystemView fileSystemView = FileSystemView.getFileSystemView(); File file = fileSystemView.getHomeDirectory(); // ?? USERPROFILE======>C:\Users\venusdrogon ? Desktop return file.getPath(); } /** * (),?360. * <ul> * <li>win7:D:\noMove\documents</li> * </ul> * * @return ? * @see FileSystemView#getDefaultDirectory() */ public static String getMyDocuments() { FileSystemView fileSystemView = FileSystemView.getFileSystemView(); File file = fileSystemView.getDefaultDirectory(); return file.getPath(); } }