Example usage for java.io File toString

List of usage examples for java.io File toString

Introduction

In this page you can find the example usage for java.io File toString.

Prototype

public String toString() 

Source Link

Document

Returns the pathname string of this abstract pathname.

Usage

From source file:edu.northwestern.bioinformatics.studycalendar.web.WebTestCase.java

public static String findWebappSrcDirectory() {
    File dir = new File("src/main/webapp");
    if (dir.exists()) {
        return dir.getPath();
    }//from w  ww.ja v  a  2 s .  c  om
    dir = new File("web", dir.toString());
    if (dir.exists()) {
        return dir.getPath();
    }
    throw new IllegalStateException("Could not find webapp path");
}

From source file:Main.java

/**
 * Notifies the MediaScanners after Downloading the GhostMySelfie, so it
 * is immediately available to the user.
 *//*from  w  w w .  ja v  a 2s  . co m*/
public static void notifyMediaScanners(Context context, File ghostmyselfieFile) {
    // Tell the media scanner about the new file so that it is
    // immediately available to the user.
    MediaScannerConnection.scanFile(context, new String[] { ghostmyselfieFile.toString() }, null,
            new MediaScannerConnection.OnScanCompletedListener() {
                public void onScanCompleted(String path, Uri uri) {
                }
            });
}

From source file:com.enprowess.migration.bulkimport.impl.FileUtils.java

/**
 * returns the filename of the given file object
 * /*from w  w w  .ja  va2 s .  c  o  m*/
 * @param file
 * @return result
 */
public static String getFileName(final File file) {
    String result = null;

    if (file != null) {
        try {
            result = file.getCanonicalPath();
        } catch (IOException ioe) {
            result = file.toString();
            logger.info(ioe);
        }
    }

    return result;
}

From source file:de.unisb.cs.st.javalanche.rhino.RhinoTestRunnable.java

public static String getCommand(String[] args) {
    StringBuilder sb = new StringBuilder();
    sb.append("java -cp ");
    String main = "org/mozilla/javascript/tools/shell/Main.class";
    URL resource = ClassLoader.getSystemResource(main);
    if (resource != null) {
        String location = resource.toString().substring(0, resource.toString().length() - main.length());
        logger.info(location);//from   www .  j a va2 s  .  com
        File f;
        try {
            f = new File(new URI(location));
            sb.append(f.toString());
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }
    // sb
    // .append(":/scratch/schuler/subjects/ibugs_rhino-0.1/jars/xmlbeans-2.2.0/lib/jsr173_1.0_api.jar:/scratch/schuler/subjects/ibugs_rhino-0.1/jars/xmlbeans-2.2.0/lib/xbean.jar");
    sb.append(":" + System.getProperty("java.class.path"));
    sb.append(" org.mozilla.javascript.tools.shell.Main ");
    for (String arg : args) {
        sb.append(arg + " ");
    }
    String message = sb.toString();
    return message;
}

From source file:Main.java

/**
 * Zip the subdirectory and exclude already zipped files
 * @param path/*from  ww  w.ja v a2s .  co m*/
 * @param srcFolder
 * @param zip
 * @param includeFullPath
 * @throws java.io.IOException
 */
static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, boolean includeFullPath)
        throws IOException {
    File folder = new File(srcFolder);

    for (String fileName : folder.list()) {
        if (path.equals("") && !fileName.endsWith(".zip")) {
            if (includeFullPath) {
                addFileToZip(folder.toString(), srcFolder + "/" + fileName, zip);
            } else {
                addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip);
            }
        } else if (!fileName.endsWith(".zip")) {
            addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip);
        }
    }
}

From source file:Main.java

public static String getSDPath() {
    File SDdir = null;
    boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
    if (sdCardExist) {
        SDdir = Environment.getExternalStorageDirectory();
    }/*from  w w  w . j a va 2  s.  com*/
    if (SDdir != null) {
        return SDdir.toString();
    } else {
        return null;
    }
}

From source file:com.iblsoft.iwxxm.webservice.Main.java

private static RequestLogHandler createAccessLogHandler(Configuration configuration, Handler handler) {
    File logFilePath = new File(configuration.getAccessLogDir(), configuration.getAccessLogFileNamePattern());

    NCSARequestLog requestLog = new NCSARequestLog(logFilePath.toString());
    requestLog.setAppend(true);//w ww.  j a v a 2s  .  com
    requestLog.setLogLatency(true);
    requestLog.setExtended(configuration.isExtendedAccessLog());
    requestLog.setLogDateFormat(configuration.getAccessLogDateTimeFormat());
    requestLog.setLogTimeZone(configuration.getAccessLogTimeZone());
    requestLog.setPreferProxiedForAddress(configuration.isProxiedAddressPreferredInAccessLog());
    requestLog.setRetainDays(configuration.getAccessLogRetainInDays());

    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    requestLogHandler.setHandler(handler);
    return requestLogHandler;
}

From source file:ImportPhagelist.java

private static String Download() throws IOException {
    String path = "http://phagesdb.org/data/?set=seq&type=full";
    String base = new File("").getAbsolutePath();
    String name = base + "/Fastas/PhagesDB_Data.txt";
    File file = new File(name);
    URL netPath = new URL(path);
    FileUtils.copyURLToFile(netPath, file);
    return file.toString();
}

From source file:Main.java

public static String getSDPath() {
    File sdDir = null;
    boolean sdCardExist = Environment.getExternalStorageState().equals("mounted");
    if (sdCardExist) {
        sdDir = Environment.getExternalStorageDirectory();
    } else {// w  w w  .  ja  va2s.co m
        sdDir = Environment.getRootDirectory();
    }

    return sdDir.toString();
}

From source file:Main.java

public static org.w3c.dom.Document read(java.io.File file) {
    try {//from  w  w  w  . ja  v  a 2s.  c om
        return read(new java.io.FileInputStream(file));
    } catch (java.io.IOException ioe) {
        throw new RuntimeException(file.toString(), ioe);
    }
    //      try {
    //         //todo?
    //         javax.xml.parsers.DocumentBuilder documentBuilder = getDocumentBuilder();
    //         synchronized( documentBuilder ) {
    //            org.w3c.dom.Document rv = documentBuilder.parse( file );
    //            return rv;
    //         }
    //      } catch( java.io.IOException ioe ) {
    //         throw new RuntimeException( file.toString(), ioe );
    //      } catch( org.xml.sax.SAXException saxe ) {
    //         throw new RuntimeException( file.toString(), saxe );
    //      }
}