Tabnine Logo
File.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
java.io.File

Best Java code snippets using java.io.File.toString (Showing top 20 results out of 23,094)

Refine searchRefine arrow

  • File.<init>
  • File.exists
  • File.isDirectory
  • File.getName
  • File.mkdirs
  • PrintStream.println
  • File.getAbsolutePath
origin: stackoverflow.com

ImageView.setImageURI(Uri.parse(new File("/sdcard/cats.jpg").toString()));
origin: apache/zookeeper

private void doFailForNonExistingPath(File file) {
  if (!file.exists()) {
    throw new IllegalArgumentException(file.toString()
        + " file is missing");
  }
}
origin: apache/storm

/**
 * Ensure the existence of a given directory.
 *
 * @throws IOException if it cannot be created and does not already exist
 */
private static void ensureDirectory(File dir) throws IOException {
  if (!dir.mkdirs() && !dir.isDirectory()) {
    throw new IOException("Mkdirs failed to create " +
               dir.toString());
  }
}
origin: FudanNLP/fnlp

public static void main(String[] args) throws Exception {
  String input1 ="D:/Datasets/sighan2006/processed";
  
  File f = new File(input1);
  if (f.isDirectory()) {
    File[] files = f.listFiles();
    for (int i = 0; i < files.length; i++) {
      processLabeledData(files[i].toString(),"utf8","gbk");
    }
  }
  System.out.println("Done");
}
origin: androidannotations/androidannotations

private File findManifestInSpecifiedPath(String androidManifestPath) throws FileNotFoundException {
  File androidManifestFile = new File(androidManifestPath);
  if (!androidManifestFile.exists()) {
    LOGGER.error("Could not find the AndroidManifest.xml file in specified path : {}", androidManifestPath);
    throw new FileNotFoundException();
  } else {
    LOGGER.debug("AndroidManifest.xml file found with specified path: {}", androidManifestFile.toString());
  }
  return androidManifestFile;
}
origin: apache/incubator-gobblin

@BeforeClass
public void setUp() throws Exception {
 this.eventBus.register(this);
 // Prepare the test url to download the job conf from
 final URL url = GobblinAWSClusterLauncherTest.class.getClassLoader().getResource(JOB_FIRST_ZIP);
 final String jobConfZipUri = getJobConfigZipUri(new File(url.toURI()));
 // Prepare the test dir to download the job conf to
 if (this.jobConfigFileDir.exists()) {
  FileUtils.deleteDirectory(this.jobConfigFileDir);
 }
 Assert.assertTrue(this.jobConfigFileDir.mkdirs(), "Failed to create " + this.jobConfigFileDir);
 final Config config = getConfig(jobConfZipUri)
     .withValue(GobblinClusterConfigurationKeys.JOB_CONF_PATH_KEY, ConfigValueFactory.fromAnyRef(this.jobConfigFileDir.toString()))
     .withValue(GobblinAWSConfigurationKeys.JOB_CONF_REFRESH_INTERVAL, ConfigValueFactory.fromAnyRef("10s"));
 this.jobConfigurationManager = new AWSJobConfigurationManager(this.eventBus, config);
 this.jobConfigurationManager.startAsync().awaitRunning();
}
origin: ReactiveX/RxJava

URL u = MaybeNo2Dot0Since.class.getResource(MaybeNo2Dot0Since.class.getSimpleName() + ".class");
String path = new File(u.toURI()).toString().replace('\\', '/');
  System.out.println("Can't find the base RxJava directory");
  return null;
File f = new File(p);
  System.out.println("Can't read " + p);
  return null;
origin: spring-projects/spring-loaded

public static String findJar(String whereToLook, String jarPrefix) {
  File dir = new File(whereToLook);
  File[] fs = dir.listFiles();
  for (File f : fs) {
    if (f.getName().startsWith(jarPrefix)) {
      return f.toString();
    }
  }
  return null;
}
origin: libgdx/libgdx

  System.out.println("Processing tileset " + tilesetName);
        System.out.println("Stripped id #" + gid + " from tileset \"" + tilesetName + "\"");
      System.out.println("Adding " + tileWidth + "x" + tileHeight + " (" + (int)tileLocation.x + ", "
        + (int)tileLocation.y + ")");
String tilesetOutputDir = outputDir.toString() + "/" + this.settings.tilesetOutputDirectory;
File relativeTilesetOutputDir = new File(tilesetOutputDir);
File outputDirTilesets = new File(relativeTilesetOutputDir.getCanonicalPath());
outputDirTilesets.mkdirs();
packer.pack(outputDirTilesets, this.settings.atlasOutputName + ".atlas");
origin: cSploit/android

public static synchronized void errorLogging(Throwable e) {
 String message = "Unknown error.",
     trace = "Unknown trace.",
     filename = (new File(Environment.getExternalStorageDirectory().toString(), ERROR_LOG_FILENAME)).getAbsolutePath();
 if (e != null) {
  if (e.getMessage() != null && !e.getMessage().isEmpty())
   message = e.getMessage();
  else if (e.toString() != null)
   message = e.toString();
  if (message.equals(mLastError))
   return;
  Writer sWriter = new StringWriter();
  PrintWriter pWriter = new PrintWriter(sWriter);
  e.printStackTrace(pWriter);
  trace = sWriter.toString();
  if (mContext != null && getSettings().getBoolean("PREF_DEBUG_ERROR_LOGGING", false)) {
   try {
    FileWriter fWriter = new FileWriter(filename, true);
    BufferedWriter bWriter = new BufferedWriter(fWriter);
    bWriter.write(trace);
    bWriter.close();
   } catch (IOException ioe) {
    Logger.error(ioe.toString());
   }
  }
 }
 setLastError(message);
 Logger.error(message);
 Logger.error(trace);
}
origin: stackoverflow.com

 // snippet taken from question
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
path = new File(path, "SubDirName");
path.mkdirs();

// initiate media scan and put the new things into the path array to
// make the scanner aware of the location and the files you want to see
MediaScannerConnection.scanFile(this, new String[] {path.toString()}, null, null);
origin: alibaba/jstorm

InputStream in = zipFile.getInputStream(entry);
try {
  File file = new File(unzipDir, entry.getName());
  if (!file.getParentFile().mkdirs()) {
    if (!file.getParentFile().isDirectory()) {
      throw new IOException("Mkdirs failed to create " +
          file.getParentFile().toString());
origin: apache/incubator-pinot

/**
 * @param segmentDirectory File pointing to segment directory
 * @param metadata segment metadata. Metadata must be fully initialized
 * @param readMode mmap vs heap map mode
 */
protected ColumnIndexDirectory(File segmentDirectory, SegmentMetadataImpl metadata, ReadMode readMode) {
 Preconditions.checkNotNull(segmentDirectory);
 Preconditions.checkNotNull(readMode);
 Preconditions.checkNotNull(metadata);
 Preconditions.checkArgument(segmentDirectory.exists(),
   "SegmentDirectory: " + segmentDirectory.toString() + " does not exist");
 Preconditions.checkArgument(segmentDirectory.isDirectory(),
   "SegmentDirectory: " + segmentDirectory.toString() + " is not a directory");
 this.segmentDirectory = segmentDirectory;
 this.metadata = metadata;
 this.readMode = readMode;
}
origin: spotbugs/spotbugs

private static void loadPluginsInDir(File pluginDir, boolean optional) {
  File[] contentList = pluginDir.listFiles();
  if (contentList == null) {
    return;
  }
  for (File file : contentList) {
    if (file.getName().endsWith(".jar")) {
      try {
        URL url = file.toURI().toURL();
        if (IO.verifyURL(url)) {
          loadInitialPlugin(url, true, optional);
          if (FindBugs.DEBUG) {
            System.out.println("Found plugin: " + file.toString());
          }
        }
      } catch (MalformedURLException e) {
      }
    }
  }
}
origin: apache/hbase

String javaCode = code != null ? code : "public class " + className + " {}";
Path srcDir = new Path(testDir, "src");
File srcDirPath = new File(srcDir.toString());
srcDirPath.mkdirs();
File sourceCodeFile = new File(srcDir.toString(), className + ".java");
BufferedWriter bw = Files.newBufferedWriter(sourceCodeFile.toPath(), StandardCharsets.UTF_8);
bw.write(javaCode);
srcFileNames.add(sourceCodeFile.toString());
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null,
 null);
String currentDir = new File(".").getAbsolutePath();
String classpath = currentDir + File.separator + "target"+ File.separator
 + "classes" + System.getProperty("path.separator")
File jarFile = new File(folder, jarFileName);
jarFile.getParentFile().mkdirs();
if (!createJarArchive(jarFile,
  new File[]{new File(srcDir.toString(), className + ".class")})){
origin: pentaho/pentaho-kettle

private static void createTempDirWithSpecialCharactersInName() throws IOException {
 if ( !TEMP_DIR_WITH_REP_FILE.exists() ) {
  if ( TEMP_DIR_WITH_REP_FILE.mkdir() ) {
   System.out.println( "CREATED: " + TEMP_DIR_WITH_REP_FILE.getCanonicalPath() );
  } else {
   System.out.println( "NOT CREATED: " + TEMP_DIR_WITH_REP_FILE.toString() );
  }
 }
}
origin: redisson/redisson

if (!file.exists()) {
  throw new FileNotFoundException(file.toString());
  path = file.getName();
boolean isDir = file.isDirectory();
if (recursive && file.isDirectory()) {
  boolean noRelativePath = StringUtil.isEmpty(path);
      String childRelativePath = (noRelativePath ? StringPool.EMPTY : path) + child.getName();
      addToZip(zos, child, childRelativePath, comment, recursive);
origin: stanfordnlp/CoreNLP

public void initLog(File logFilePath) throws IOException {
 RedwoodConfiguration.empty()
  .handlers(RedwoodConfiguration.Handlers.chain(
   RedwoodConfiguration.Handlers.showAllChannels(), RedwoodConfiguration.Handlers.stderr),
   RedwoodConfiguration.Handlers.file(logFilePath.toString())
  ).apply();
 // fh.setFormatter(new NewlineLogFormatter());
 System.out.println("Starting Ssurgeon log, at "+logFilePath.getAbsolutePath()+" date=" + DateFormat.getDateInstance(DateFormat.FULL).format(new Date()));
 log.info("Starting Ssurgeon log, date=" + DateFormat.getDateInstance(DateFormat.FULL).format(new Date()));
}
origin: FudanNLP/fnlp

/**
 * @param fileName
 */
public void read(String fileName) {
  File f = new File(fileName);
  if (f.isDirectory()) {
    File[] files = f.listFiles();
    for (int i = 0; i < files.length; i++) {
      read(files[i].toString());
    }
  } else {
    try {
      InputStreamReader read = new InputStreamReader(
          new FileInputStream(fileName), "utf-8");
      BufferedReader bin = new BufferedReader(read);
      String sent;
      while ((sent = bin.readLine()) != null) {
        calc(sent);
      }
    } catch (Exception e) {
    }
  }
}
origin: jeremylong/DependencyCheck

/**
 * Deletes any files extracted from the JAR during analysis.
 */
@Override
public void closeAnalyzer() {
  if (tempFileLocation != null && tempFileLocation.exists()) {
    LOGGER.debug("Attempting to delete temporary files from `{}`", tempFileLocation.toString());
    final boolean success = FileUtils.delete(tempFileLocation);
    if (!success && tempFileLocation.exists()) {
      final String[] l = tempFileLocation.list();
      if (l != null && l.length > 0) {
        LOGGER.warn("Failed to delete the JAR Analyzder's temporary files from `{}`, "
            + "see the log for more details", tempFileLocation.getAbsolutePath());
      }
    }
  }
}
java.ioFiletoString

Javadoc

Returns a string containing a concise, human-readable description of this file.

Popular methods of File

  • <init>
    Creates a new File instance by converting the givenfile: URI into an abstract pathname. The exact fo
  • exists
    Tests whether the file or directory denoted by this abstract pathname exists.
  • getAbsolutePath
    Returns the absolute pathname string of this abstract pathname. If this abstract pathname is already
  • getName
    Returns the name of the file or directory denoted by this abstract pathname. This is just the last n
  • isDirectory
  • mkdirs
  • delete
    Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a director
  • listFiles
    Returns an array of abstract pathnames denoting the files and directories in the directory denoted b
  • getParentFile
    Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not
  • getPath
    Converts this abstract pathname into a pathname string. The resulting string uses the #separator to
  • isFile
  • length
    Returns the length of the file denoted by this abstract pathname. The return value is unspecified if
  • isFile,
  • length,
  • toURI,
  • createTempFile,
  • createNewFile,
  • toPath,
  • mkdir,
  • lastModified,
  • getCanonicalPath

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • scheduleAtFixedRate (Timer)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Option (scala)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now