读取文件,生成随机文件名

// 读取数据
	public String ReaderjsonAll(String url) {
		StringBuffer text = new StringBuffer();
		BufferedReader br = null;
		try {
			br = new BufferedReader(new InputStreamReader(new FileInputStream(url), "gbk"));
			String line = br.readLine();
			while (null != line) {
				text.append(line);
				line = br.readLine();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		LOG.info("测试读取数据"+text.toString());
		return text.toString();
	}



//生成指定文件名的文件
 public static String filePath(String path)throws Exception{

        String savePath = path;
        String uuid = UUID.randomUUID().toString().replace("-", "");//随机字串
        String suffix = ".html";
        String randomName = uuid+suffix;
        String fullName = savePath + File.separator + randomName;

        File file2=new File(fullName);
        file2.createNewFile();



        return file2.toString();

    }

你可能感兴趣的:(java)