本文整理汇总了Java中java.io.File.toString方法的典型用法代码示例。如果您正苦于以下问题:Java File.toString方法的具体用法?Java File.toString怎么用?Java File.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFileBrowser
import java.io.File; //导入方法依赖的package包/类
private void openFileBrowser() {
//Selecting the "EXAMES_APP" Folder as default
File root = android.os.Environment.getExternalStorageDirectory();
File dir = new File(root.getAbsolutePath() + "/Exames-App/");
String directoryy = dir.toString();
//Giving the FilePicker a custom Title:
String title = "Selecione um dos Exames";
new MaterialFilePicker()
.withActivity(MainActivity.this)
.withRequestCode(1)
.withFilter(Pattern.compile(".*\\.pdf$"))
.withFilterDirectories(false) // Set directories filterable (false by default)
.withHiddenFiles(false) // Show hidden files and folders
.withRootPath(directoryy)
.withTitle(title)
.start();
}
示例2: longClickPageFiles
import java.io.File; //导入方法依赖的package包/类
private void longClickPageFiles(String url) {
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
String bookmarkUrl=Constants.FILE + bookmarkWebPage.toString();
LightningView lv=getCurrentWebView();
if(lv==null){
return;
}
String webUrl=lv.getUrl();
if(webUrl.equalsIgnoreCase(bookmarkUrl)){
openBookmarkUrlLongClick(url);
return;
}
File historyWebPage = new File(this.getFilesDir(), "history.html");
String historyUrl= Constants.FILE + historyWebPage;
if(webUrl.equalsIgnoreCase(historyUrl)){
openHistoryUrlLongClick(url);
return;
}
}
示例3: findProjectsForSingleFiles
import java.io.File; //导入方法依赖的package包/类
/**
* Collects the projects containing the given single source files.
*
* @param sourceFiles
* the list of single source files
* @return list of N4JS project locations
* @throws N4JSCompileException
* if no project cannot be found for one of the given files
*/
private List<File> findProjectsForSingleFiles(List<File> sourceFiles)
throws N4JSCompileException {
Set<URI> result = Sets.newLinkedHashSet();
for (File sourceFile : sourceFiles) {
URI sourceFileURI = URI.createFileURI(sourceFile.toString());
URI projectURI = n4jsFileBasedWorkspace.findProjectWith(sourceFileURI);
if (projectURI == null) {
throw new N4JSCompileException("No project for file '" + sourceFile.toString() + "' found.");
}
result.add(projectURI);
}
// convert back to Files:
return result.stream().map(u -> new File(u.toFileString())).collect(Collectors.toList());
}
示例4: onExit
import java.io.File; //导入方法依赖的package包/类
private void onExit(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onExit
try {
//snap config
final File f = FileUtils.getLastChooserPath();
if (f != null){
config.lastPath = f.toString();
}
//try to save config
FileUtils.writeObject(new File(CONFIG_PATH), config);
} catch (Exception ex) {
Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
}
System.exit(0);
}
示例5: createConfigs
import java.io.File; //导入方法依赖的package包/类
public static void createConfigs(File configFile)
{
ConfigData configData = new ConfigData();
configData.coolqDir = "./coolq";
configData.qqBotPort = 11235;
configData.qqBotNumber = "10000";
configData.telegramBotToken = "";
GroupsPairs sample = new GroupsPairs();
sample.qqGroup = 10000;
sample.telegramGroup = -1;
configData.groupsPairs = new ArrayList<GroupsPairs>();
configData.groupsPairs.add(sample);
configData.proxyConfig = new ProxyConfig();
configData.proxyConfig.enableProxy = false;
configData.proxyConfig.proxyType = "SOCKS";
configData.proxyConfig.proxyHost = "127.0.0.1";
configData.proxyConfig.proxyPort = 1080;
configData.enabledPlugins = new ArrayList<String>();
configData.enabledPlugins.add("plugins.Transport");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String JSONString = gson.toJson(configData);
try
{
FileWriter out = new FileWriter(configFile.toString());
out.write(JSONString);
out.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
示例6: getClassName
import java.io.File; //导入方法依赖的package包/类
private static String getClassName(File file) {
Matcher matcher = JAVA_FILE_RX.matcher(file.toString());
if (matcher.matches()) {
return matcher.group(1).replace('/', '.');
}
return file.toString();
}
示例7: isExternalJar
import java.io.File; //导入方法依赖的package包/类
/**
* Returns true is file has the same name as one of the JARs marked for
* indirect inclusion through separate jnlp component instead of directly.
* @param file
* @param extJars
* @return true if file is not to be included in main jnlp directly
*/
private static boolean isExternalJar(File file, Set<? extends String> extJars) {
if(file != null && extJars != null) {
String fileStr = file.toString();
for(String extJar : extJars) {
if(fileStr.contains(extJar)) {
return true;
}
}
}
return false;
}
示例8: addFiles
import java.io.File; //导入方法依赖的package包/类
/**
* 将文件夹中文件添加到队列中
* @param folders 需要上传文件的文件夹集合
*/
public static void addFiles(String[] folders) {
String[] file_types = constant.FILE_TYPE_FILTER.split(",");
for (String folder : folders) {
File file = new File(folder);
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
String s1 = f.toString();
if (!f.isDirectory() && !s1.contains("COMPLETED_")) {
for (String s2 : file_types) {
int l1 = s1.length();
int l2 = s2.length();
String s3 = s1.substring(l1-l2,l1);
if (s3.equals(s2)) {
try {
blockingQueue.put(s1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
}
}
示例9: FileHash
import java.io.File; //导入方法依赖的package包/类
public FileHash(File file) {
this.file = file.toString();
try {
this.hash = getFileChecksum(file);
} catch (IOException e) {
OneClientLogging.error("{} {}", file, e);
}
}
示例10: setUp
import java.io.File; //导入方法依赖的package包/类
/**
* Sets up logging facilities.
*/
@Override
public void setUp() {
System.out.println("######## "+getName()+" #######");
err = getLog();
log = getRef();
JemmyProperties.getProperties().setOutput(new TestOut(null,
new PrintWriter(err, true), new PrintWriter(err, false), null));
try {
File wd = getWorkDir();
workDir = wd.toString();
} catch (IOException e) { }
openDefaultProject();
}
示例11: resolve
import java.io.File; //导入方法依赖的package包/类
/**
* Adds [relative] file to this, considering this as a directory.
* If [relative] has a root, [relative] is returned back.
* For instance, `File("/foo/bar").resolve(File("gav"))` is `File("/foo/bar/gav")`.
* This function is complementary with [relativeTo],
* so `f.resolve(g.relativeTo(f)) == g` should be always `true` except for different roots case.
*
* @return concatenated this and [relative] paths, or just [relative] if it's absolute.
*/
public static File resolve( @This File thiz, File relative )
{
if( relative.isRooted() )
{
return relative;
}
String baseName = thiz.toString();
return baseName.isEmpty() || baseName.endsWith( File.separator )
? new File( baseName + relative )
: new File( baseName + File.separatorChar + relative );
}
示例12: save
import java.io.File; //导入方法依赖的package包/类
public String save(String fileName) {
if (fileName == null || fileName.isEmpty()) {
return null;
}
String fileNameWithExtension = fileName;
if (!fileNameWithExtension.endsWith("." + FILE_EXTENSION)) {
fileNameWithExtension += "." + FILE_EXTENSION;
}
File newFile = new File(fileNameWithExtension);
try (FileOutputStream fileOut = new FileOutputStream(newFile)) {
JAXBContext jaxbContext = JAXBContext.newInstance(Map.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
// first: marshal to byte array
jaxbMarshaller.marshal(this, out);
out.flush();
// second: postprocess xml and then write it to the file
XmlUtilities.saveWithCustomIndetation(new ByteArrayInputStream(out.toByteArray()), fileOut, 1);
out.close();
jaxbMarshaller.marshal(this, out);
} catch (JAXBException | IOException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
return newFile.toString();
}
示例13: setupTestDirs
import java.io.File; //导入方法依赖的package包/类
@BeforeClass
public static void setupTestDirs() throws IOException {
testWorkDir = new File("target",
TestLocalContainerLauncher.class.getCanonicalName());
testWorkDir.delete();
testWorkDir.mkdirs();
testWorkDir = testWorkDir.getAbsoluteFile();
for (int i = 0; i < localDirs.length; i++) {
final File dir = new File(testWorkDir, "local-" + i);
dir.mkdirs();
localDirs[i] = dir.toString();
}
}
示例14: mapAlternativeName
import java.io.File; //导入方法依赖的package包/类
/**
* Returns an alternate path name for the given file
* such that if the original pathname did not exist, then the
* file may be located at the alternate location.
* For mac, this replaces the final .dylib suffix with .jnilib
*/
static File mapAlternativeName(File lib) {
if (!ikvm.internal.Util.MACOSX) {
return null;
}
String name = lib.toString();
int index = name.lastIndexOf('.');
if (index < 0) {
return null;
}
return new File(name.substring(0, index) + ".jnilib");
}
示例15: setupBinaries
import java.io.File; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@PostConstruct
public void setupBinaries()
{
if( disableConversion )
{
return;
}
// Test for the Java install
File javaBinDir = new File(javaHome, "bin");
if( !javaBinDir.exists() || !javaBinDir.isDirectory() )
{
throw new RuntimeException(
"Error setting conversionService.javaPath: Java directory not found at " + javaBinDir);
}
File javaExeFile = ExecUtils.findExe(javaBinDir, "java");
if( javaExeFile == null )
{
throw new RuntimeException(
"Error setting conversionService.javaPath: Java executable not found in " + javaBinDir);
}
this.javaExe = javaExeFile.toString();
// Test for the conversion service
File cjFile = new File(conversionJar);
if( !cjFile.exists() || cjFile.isDirectory() )
{
throw new RuntimeException(
"Error setting conversionService.conversionServicePath: Conversion service JAR does not exist at "
+ cjFile);
}
this.conversionDir = cjFile.getParentFile();
}