首页 > 解决方案 > 创建新文件时如何停止 Groovy 用单个正斜杠替换多个正斜杠

问题描述

我通过 aws S3 访问了以下文件:

s3://ngi-igenomes/igenomes/Homo_sapiens/NCBI/GRCh38/Annotation/Genes/genes.gtf

我制作了一个检查文件内容的函数,并且适用于本地文件。考虑以下:

gtf_file_str = 's3://ngi-igenomes/igenomes/Homo_sapiens/NCBI/GRCh38/Annotation/Genes/genes.gtf'
println gtf_file_str
File gtf_file = new File(gtf_file_str)
println gtf_file

执行此操作时,我得到以下信息:

s3://ngi-igenomes/igenomes/Homo_sapiens/NCBI/GRCh38/Annotation/Genes/genes.gtf
s3:/ngi-igenomes/igenomes/Homo_sapiens/NCBI/GRCh38/Annotation/Genes/genes.gtf

然后我的函数无法识别gtf_file,因为它已经摆脱了双正斜杠并将其替换为单斜杠。如何阻止它替换双正斜杠?

标签: javaamazon-s3groovy

解决方案


推荐阅读