草庐IT

config-files

全部标签

Java file.getPath() 返回语言修改路径

我需要用fileChooser.getSelectedFile()方法但是它总是返回语言修改路径,因为一些目录在osX中被翻译。例如,文件夹“/Downloads”被翻译成我的系统语言“/Stiahnuté”,但实际路径是“/Downloads”返回:/Users/John/Stiahnuté期待/Users/John/Downloads如果我选择了一些子目录,那么fileChooser.getSelectedFile()会再次返回正确的路径。看起来总是只翻译路径中的最后一个目录/Users/John/Downloads/subDirectory代码:saveButton.addAct

java - Spring Boot - 大量无效请求和套接字接受失败 java.io.IOException : Too many open files

我的机器运行着Spring(SpringBoot1.5.2.RELEASE)应用程序。最近我在我的日志文件中收到了很多警告:.w.s.m.s.DefaultHandlerExceptionResolver:FailedtoreadHTTPmessage:org.springframework.http.converter.HttpMessageNotReadableException:Couldnotreaddocument:null;nestedexceptionisjava.net.SocketTimeoutException我已经检查过tcpdump并且很多请求没有正文(空/空)

为 glob 或类似 Ant 的模式 "*foo/**/*.txt"返回 List<File> 的 Java 库?

我正在寻找一个库,它会提供一种方法,该方法会给我一个匹配给定类Ant模式的文件列表。对于*foo/**/*.txt我会得到foo/x.txtfoo/bar/baz/.txtmyfoo/baz/boo/bar.txt等我知道这可以通过DirWalker和PathMatchermat=FileSystems.getDefault().getPathMatcher("glob:"+filesPattern);,但我更喜欢一些维护的库。我希望CommonsIO拥有它,但没有。更新:我很高兴重用Ant的代码,但更喜欢比整个Ant更小的东西。 最佳答案

java - 使用 Java Config 的 Spring Security 无法使用 eraseCredentials 方法

使用SpringSecurity3.2.2和SpringFramework3.2.8的以下JavaConfig配置,即使我使用“.eraseCredentials(false)”,用户密码也会被删除,并且它无法使用authentication.getCredentials()。@Configuration@EnableWebSecurity@Order(1)publicclassSecurityConfigextendsWebSecurityConfigurerAdapter{@Bean(name="authenticationEntryPoint")publicLoginUrlAut

java - 在 Java 中 : "Too many open files" error when reading from a network path

我有下面的代码,它只是从一个文件夹中读取所有文件。此文件夹中有20,000个文件。该代码在本地文件夹(d:/files)上运行良好,但在读取大约1,000-2,000个文件后在网络路径(//robot/files)上运行失败。更新:文件夹是彼此的副本。导致此问题的原因以及如何解决?packagecef_debug;importjava.io.*;publicclassMain{publicstaticvoidmain(String[]args)throwsThrowable{Stringfolder=args[0];File[]files=(newFile(folder)).listF

java - Files.copy(Path,Path) 是否创建目录?

我的Java程序目录(C:/Users/java/dir1)下有一堆文本文件(比如ss1.txt、ss2.txt、ss3.txt等)?我想将我的txt文件移动到一个尚未创建的新目录。我的所有文件都有一个字符串地址,我想我可以使用将它们变成路径路径path=Paths.get(textPath);将创建一个字符串(C:/Users/java/dir2),使用上述方法将其转换为路径,然后使用Files.copy(C:/Users/java/dir1/ss1.txt,C:/Users/java/dir2)导致ss1.text被复制到新目录? 最佳答案

java.io.File.setReadable(false) 在 docker 中无效

以下代码在使用OpenJDK8的Ubuntu18.04上成功,但在基于OpenJDK8的Docker镜像maven:3-jdk-8-slim中失败:StringuserHome=System.getProperty("user.home");System.out.println(String.format("systempropertyuser.home:%s",userHome));Filefile=newFile(userHome,"file");if(!file.createNewFile()){thrownewIOException("testarrangementfailed

git pull 时 配置适合自己的合并策略 git config pull.rebase

当gitpull时有可能遇到以下的提示hint:gitconfigpull.rebasefalse#merge(thedefaultstrategy)hint:gitconfigpull.rebasetrue#rebasehint:gitconfigpull.ffonly#fast-forwardonly这三个配置项影响gitpull的默认行为。以下是对它们的详细解释:1.默认合并策略(gitconfigpull.rebasefalse)前提条件:本地分支上有一系列提交(gitcommit),远程分支上也有一系列提交。后续变化:执行gitpull后,Git会创建一个新的合并提交,将本地分支和远

java - File.renameTo 和 Files.move : Which is faster? 的区别

Java中的File.renameTo和Files.move都可以移动文件。两者有什么区别?哪个性能更好? 最佳答案 publicbooleanrenameTo(Filedest)Renamesthefiledenotedbythisabstractpathname.Manyaspectsofthebehaviorofthismethodareinherentlyplatform-dependent:Therenameoperationmightnotbeabletomoveafilefromonefilesystemtoanoth

java - Spring Cloud Config Server 环境变量的优先级

我对使用springcloudconfigserver时环境变量的优先级有疑问在我的服务中,我有一个包含此内容的本地属性文件application.ymlfoo:bar:"some"buz:"some"joe:"some"该服务还连接到配置服务器,配置存储库包含文件testservice-api.yml(其中testservice-api是spring应用程序名称服务)。该文件的内容是:foo:bar:"some-specific"因此,使用此设置,运行时的配置将导致:{"foo.bar":"some-specific","foo.buz":"some","foo.joe":"some