关于java的收集

本文提供了一段Java代码实例,用于获取指定目录路径并验证其存在性,同时展示了如何创建不存在的文件夹。适用于Java开发中文件路径操作的需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

获取java目录的路径

http://ahomeeye.iteye.com/blog/896534

 

 java正则表达式教程

http://www.java3z.com/cwbwebhome/article/article8/Regex/Java.Regex.Tutorial.html#reg9_3

java读取Map集合的方法

http://yuexiaowen.iteye.com/blog/504929

关于获取地址的问题

<%
 String basePath = request.getScheme() + "s://"
   + request.getServerName() + ":" + request.getServerPort()
   + request.getContextPath();
%>

 

关于生成文件夹的代码(带文件夹验证):

 

 

import java.io.*;

public class Demo
{
  public static void main( String[] args)
  {
    File   dirFile;
    File   tempFile;
    boolean bFile;
    String   sFileName;
    
    bFile = false;

    try
    {
        dirFile = new File("E://test");
        bFile   = dirFile.exists();//验证文件夹是否存在

        if( bFile == true )
        {
          System.out.println("The folder exists.");
        }
        else
        {
          System.out.println("The folder do not exist,now trying to create a one...");
          bFile = dirFile.mkdir();//开始创建文件夹
          if( bFile == true )
          {
            System.out.println("Create successfully!");
          }
          else
          {
            System.out.println("Disable to make the folder,please check the disk is full or not.");
            System.exit(1);
          }
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值