草庐IT

input-type-file

全部标签

java - 模式语法异常 : Unexpected internal error near index 1 for `.split(File.separator)` under windows

下面的代码片段在linux下工作正常,但在windows下给我错误(这很奇怪,因为jvm/jdk应该是操作系统不可知的)。Filef=...String[]split=f.getPath().split(File.separator);这里是错误:java.util.regex.PatternSyntaxException:Unexpectedinternalerrornearindex1\^atjava.util.regex.Pattern.error(UnknownSource)atjava.util.regex.Pattern.compile(UnknownSource)atja

java - 访问限制 : The type 'BASE64Decoder' is not API

这个问题在这里已经有了答案:EncodingasBase64inJava(19个回答)关闭3年前。我正在尝试将旧项目转换为Maven项目。但是当项目是maven时,它会在带有导入的类上显示警告:importsun.misc.BASE64Decoder;importsun.misc.BASE64Encoder;Accessrestriction:Thetype'BASE64Decoder'isnotAPI(restrictiononrequiredlibrary'C:\ProgramFiles\Java\jre7\lib\rt.jar')那么它有什么问题呢?

java.util.zip.ZipException : too many entries in ZIP file

我正在尝试编写一个Java类来提取包含约74000个XML文件的大型zip文件。尝试使用javazip库解压缩它时出现以下异常:java.util.zip.ZipException:ZIP文件中条目太多不幸的是,由于项目的要求,我无法在zip到达我之前对其进行分解,并且解压缩过程必须自动化(无需手动步骤)。有什么方法可以利用java.util.zip或某些第3方Javazip库来解决此限制?谢谢。 最佳答案 使用ZipInputStream而不是ZipFile应该可以做到这一点。 关于j

JAR 中的 Java Desktop.open(File f) 引用文件?

Desktop.open(Filef)可以引用位于JAR中的文件吗?我尝试使用ClassLoader.getResource(Strings),将其转换为URI,然后从中创建文件。但这会导致IllegalArgumentException:URIisnothierarchical。URLurl=ClassLoader.getSystemClassLoader().getResource(...);System.out.println("url="+url);//urlisvalidDesktop.getDesktop().open(newFile(url.toURI()));一种可能性

Java : Expose only a single package in a jar file

我想要一个只有API包可以访问的jar文件。所有其他包(包含实现)将无法被另一个jar(或任何其他类)访问。这可能吗?如果是,怎么办? 最佳答案 当前计划用于Java8(2012年?)的是JSR294.此JSR将更好的模块化语言结构引入Java。Today,animplementationcanbepartitionedintomultiplepackages.Subpartsofsuchanimplementationneedtobemoretightlycoupledtoeachotherthantothesurrounding

java - maven 安装仅在第二次尝试后抛出 "error in opening zip file"

我尝试在我的项目上使用一些依赖项运行maveninstall:log4jlog4j1.2.15org.slf4jslf4j-log4j121.5.2ch.qos.logbacklogback-classic0.9.24org.hibernatehibernate-core3.3.2.GAorg.hibernatehibernate-annotations3.4.0.GA我第一次运行mvninstall它运行得很好(构建成功)但是第二次(“在我对代码进行一些更改之后”)我尝试运行mvninstall并且maven抛出“打开zip文件时出错”。[ERROR]error:errorreadi

java - 使用 gson 反序列化时将 TypeToken 转换为 Type 时出错

我有一个类使用此函数反序列化泛型的ArrayList,正如该线程的第一个答案中所述:JavaabstractclassfunctiongenericTypepublicArrayListarrayType(Stringdata){returng.fromJson(data,TypeToken.get(newArrayList().getClass()));}Eclipse要求我强制转换TypeToken结果(因为来自Json的函数需要类型,而不是TypeToken)publicArrayListarrayType(Stringdata){returng.fromJson(data,(T

已解决1:STM32+SYN6288语音模块中文播报汉字乱码;2:警告: passing ‘char [5O]’to parame ter of type ‘uos o’(aka ‘unsigned

目录遇到的问题1:使用STM32+SYN6288语音模块时,可以正常进行英文和数字的播报,但改为中文进行播报时,播报的是乱码汉字。遇到的问题2:出现警告warning:passing'char[5O]’toparameteroftype'uoso’(aka'unsignedchar*)convertsbetweenpointerstointegertypeswithdifferentsign修改处源码两个问题亲测无误,完美解决。源码来自:绿深旗舰店SYN6288语音合成模块STM32F405RGT6测试程序所用模块:绿深SYN6288语音合成模块遇到的问题1:使用STM32+SYN6288语音

java.lang.AssertionError : Content type not set - Spring Controller Junit Tests 错误

我正在尝试对我的Controller进行一些单元测试。无论我做什么,所有Controller测试都会返回java.lang.AssertionError:Contenttypenotset我正在测试这些方法是否返回json和xml数据。这里是Controller的例子:@Controller@RequestMapping("/mypath")publicclassMyController{@AutowiredMyServicemyService;@RequestMapping(value="/schema",method=RequestMethod.GET)publicResponse

Java 错误 - 错误的源文件 : file does not contain class x . 请删除或确保它出现

最近为了考试开始学习Java。在学习包时,尝试了这个并得到了一条错误消息。我做的是//CreatingclassA(Withinpackagethepackage:com.test.helpers)packagecom.test.helpers;publicclassA{publicvoidsayHello(){System.out.println("HelloWorld");}}//AndthentheclassApputilisingtheclassAimportcom.test.helpers.*;publicclassApp{publicstaticvoidmain(Strin