线程安全spring mvc controller java.io.IOException: Stream closed异常

程序的流程是客户端发送一个Http post请求请求的内容是一个xml文件,服务器通过spring mvc 的controller接收
然后response 返回xml
@Controller
public class QueryController {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {

                    //业务处理.....
   }

}
类似上面的调用,间隔时间比较短的情况下会出现下面的异常,分析原因是Spring MVC的controller不是线程安全的,每次请求都是同一个servlet,当第一次请求的reponse或request关闭后,接下来的请求就会出现stream closed的情况。

尝试了几种方式:
1.用ThreadLocal管理request response 问题依然存在
2.尝试把处理写成无状态,线程安全的视乎很难
3.SingleThreadModel ,synchronized 管理好像也不行,感觉无法控制response和request对象。

现在的想法是把这个servlet变成线程安全,尝试了下视乎配置的不对,希望大家指点。

还有就是像这样的业务比较好的解决方法是什么,也请大家分享一下。

java.io.IOException: Stream closed
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:406)
at org.apache.catalina.connector.CoyoteReader.read(CoyoteReader.java:105)
at org.apache.xmlbeans.impl.piccolo.xml.XMLReaderReader.fillCharBuffer(XMLReaderReader.java:247)
at org.apache.xmlbeans.impl.piccolo.xml.XMLReaderReader.reset(XMLReaderReader.java:84)
at org.apache.xmlbeans.impl.piccolo.xml.DocumentEntity.open(DocumentEntity.java:74)
at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.reset(PiccoloLexer.java:982)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:709)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3454)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1329)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1316)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:360)
at org.poc.pos.obervationQuery.QueryObservationRequestDocument$Factory.parse(Unknown Source)
at com.yuxin.referral.services.ObservationQueryServiceImpl.ObservationQueryRequest(ObservationQueryServiceImpl.java:79)
at com.yuxin.referral.services.ObservationQueryServiceImpl$$FastClassByCGLIB$$27758ac0.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
at com.yuxin.referral.services.ObservationQueryServiceImpl$$EnhancerByCGLIB$$e00082b7.ObservationQueryRequest()
at com.yuxin.referral.web.ObservationQueryController.handleRequest(ObservationQueryController.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at com.springsource.metrics.collection.web.HttpRequestMetricCollectionValve.invoke(HttpRequestMetricCollectionValve.java:44)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:379)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)

1个回答

servlet 怎么可能线程安全呢。
不然怎么并发, response close 的应该有问题,你应该在close后还做了相关的operation。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
org.apache.catalina.connector.ClientAbortException: java.io.IOException

问题描述 : 1. 仅当静态资源请求时触发 2. 仅是火狐浏览器触发 3. 仅当Tomcat7以上触发 4. 有个类似的项目不触发此异常 其中触发错误的请求: /livestock/res/assets/ico/apple-touch-icon-152x152.png /livestock/res/assets/vendor/font-awesome/fonts/fontawesome-webfont.woff2 神奇的bug ``` org.apache.catalina.connector.ClientAbortException: java.io.IOException: APR error: -730053 at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:393) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:418) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:406) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:97) at org.springframework.util.StreamUtils.copy(StreamUtils.java:138) at org.springframework.http.converter.ResourceHttpMessageConverter.writeContent(ResourceHttpMessageConverter.java:110) at org.springframework.http.converter.ResourceHttpMessageConverter.writeInternal(ResourceHttpMessageConverter.java:102) at org.springframework.http.converter.ResourceHttpMessageConverter.writeInternal(ResourceHttpMessageConverter.java:45) java.io.IOException: APR error: -730053 at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:226) at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:480) at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2463) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2452) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) ```

奇葩问题java.io.IOException: Error writing to server

用java swing 做了一个客户端,手动模拟http请求,在个别xp和win10中出现服务器写入错误。 错误信息如下: java.io.IOException: Error writing to server at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:626) at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:638) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322) at com.tysi.common.http.HttpRequester.makeContent(HttpRequester.java:95) at com.tysi.common.http.HttpRequester.send(HttpRequester.java:88) at com.tysi.common.http.HttpRequester.sendPost(HttpRequester.java:39) at com.tysi.client.login.FerryClientLogin.checkLoginUrl(FerryClientLogin.java:530) at com.tysi.client.login.FerryClientLogin.LoginEvent(FerryClientLogin.java:412) at com.tysi.client.login.FerryClientLogin$11.mouseClicked(FerryClientLogin.java:372) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270) at java.awt.Component.processMouseEvent(Component.java:6519) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6281) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4872) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4698) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4698) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747) at java.awt.EventQueue.access$300(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:706) at java.awt.EventQueue$3.run(EventQueue.java:704) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:720) at java.awt.EventQueue$4.run(EventQueue.java:718) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:717) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 代码如下: private HttpRespons makeContent(String urlString, HttpURLConnection urlConnection) throws IOException { HttpRespons httpResponser = new HttpRespons(); try { InputStream in = urlConnection.getInputStream(); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(in)); httpResponser.contentCollection = new Vector(); StringBuffer temp = new StringBuffer(); String line = bufferedReader.readLine(); while (line != null) { httpResponser.contentCollection.add(line); temp.append(line).append("\r\n"); line = bufferedReader.readLine(); } 在InputStream in = urlConnection.getInputStream();抛出异常 求各位大神帮忙,实在不知道是什么原因导致的。

idea编译出错 java.io.IOException: Cannot create empty file:

Error:Internal error: (java.io.IOException) Cannot create empty file: C:\Users\鏋楁案鍩�\.IntelliJIdea2019.1\system\compile-server\schoolrollsystem_d8001572\timestamps\data java.io.IOException: Cannot create empty file: C:\Users\鏋楁案鍩?\.IntelliJIdea2019.1\system\compile-server\schoolrollsystem_d8001572\timestamps\data at com.intellij.util.io.PersistentEnumeratorBase.<init>(PersistentEnumeratorBase.java:175) at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:73) at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:47) at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:163) at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:152) at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:143) at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:135) at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:128) at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:124) at org.jetbrains.jps.incremental.storage.AbstractStateStorage.<init>(AbstractStateStorage.java:27) at org.jetbrains.jps.incremental.storage.TimestampStorage.<init>(TimestampStorage.java:21) at org.jetbrains.jps.incremental.storage.ProjectTimestamps.<init>(ProjectTimestamps.java:35) at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:111) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:279) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228) at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Please perform full project rebuild (Build | Rebuild Project)

启动web harvest的时候出现Caused by: java.io.IOException: Could not get shel

当使用java -jar命令的时候,出现如下异常,请各位看看,我还是新手: d:\work\tec_crawlers>java -jar webharvest.jar Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at org.webharvest.gui.Ide.<init>(Unknown Source) at CommandLine$1.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) Caused by: java.lang.RuntimeException: java.io.IOException: Could not get shell folder ID list at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1223) at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:557) at sun.awt.shell.Win32ShellFolder2.composePathForCsidl(Win32ShellFolder2.java:211) at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:224) at sun.awt.shell.Win32ShellFolderManager2.getNetwork(Win32ShellFolderManager2.java:123) at sun.awt.shell.Win32ShellFolder2$7.call(Win32ShellFolder2.java:541) at sun.awt.shell.Win32ShellFolder2$7.call(Win32ShellFolder2.java:538) at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1214) at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:538) at sun.awt.shell.Win32ShellFolder2.access$400(Win32ShellFolder2.java:55) at sun.awt.shell.Win32ShellFolder2$11.call(Win32ShellFolder2.java:711) at sun.awt.shell.Win32ShellFolder2$11.call(Win32ShellFolder2.java:702) at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1214) at sun.awt.shell.Win32ShellFolder2.getChildByPath(Win32ShellFolder2.java:702) at sun.awt.shell.Win32ShellFolderManager2.getPersonal(Win32ShellFolderManager2.java:137) at sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:652) at sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:639) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor$2.run(Win32ShellFolder2.java:1180) at java.lang.Thread.run(Thread.java:619) Caused by: java.io.IOException: Could not get shell folder ID list at sun.awt.shell.Win32ShellFolder2.getFileSystemPath0(Native Method) at sun.awt.shell.Win32ShellFolder2.access$1000(Win32ShellFolder2.java:55) at sun.awt.shell.Win32ShellFolder2$8.call(Win32ShellFolder2.java:559) at sun.awt.shell.Win32ShellFolder2$8.call(Win32ShellFolder2.java:557) at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1214) ... 22 more

java多线程报错 java.io.IOException: Stream closed

虽然程序可以正确的讲读取到的信息输出到文本文件 但是报错:java.io.IOException: Stream closed 不知道是什么原因 菜鸟请各位帮忙看一下 代码如下: package test; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Test implements Runnable{ String lineString; public Test(String line){ this.lineString = line; } static FileWriter writer; static FileReader reader; public static void main(String[] args) throws IOException { try { reader = new FileReader("/Users/tcredit-0002/Desktop/car.txt"); Scanner scanner = new Scanner(reader); String lineString; writer = new FileWriter("/Users/tcredit-0002/Desktop/hebei.txt"); // TODO Auto-generated method stub ExecutorService pool = Executors.newFixedThreadPool(3); while(scanner.hasNext()){ lineString = scanner.nextLine(); pool.execute(new Test(lineString)); } scanner.close(); writer.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void run() { try { writeResult(lineString); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static synchronized void writeResult(String lineString) throws InterruptedException{ try { writer.write(lineString+"\r\n"); writer.flush(); System.out.println(lineString); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }

java.io.IOException: 拒绝访问。

我在web项目中需要创建文件 我在eclipse里面测试没问题 在tomcat里就报错 java.io.IOException: 拒绝访问。 有没有人告诉我是怎么回事,该怎样解决。谢谢 [b]问题补充:[/b] java.io.IOException: 拒绝访问。 at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:850) [b]问题补充:[/b] 请告诉我该怎么解决。 [b]问题补充:[/b] 我在目录下创建了一个文件 进行操作没有问题 文件夹已经存在 就是创建文件 出错 这是权限问题吗? if(CURFILE.equals("")){ //CURFILE=getCurFile(); CURFILE="aa.log"; } System.out.println(ROOT+File.separator+BASE+File.separator+sysdate+File.separator+CURFILE); File file=new File(ROOT+File.separator+BASE+File.separator+sysdate+File.separator+CURFILE); if(!file.exists()){ f.createNewFile(); }

java.io.IOException: APR error: -120001

导出文件时发生的错误,可能是因为文件过大?文件大概300MB,有时成功,有时报这个错误 ``` java.io.IOException: APR error: -120001 at org.apache.coyote.http11.InternalAprOutputBuffer.writeToSocket(InternalAprOutputBuffer.java:292) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.InternalAprOutputBuffer.writeToSocket(InternalAprOutputBuffer.java:245) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:214) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.InternalAprOutputBuffer.addToBB(InternalAprOutputBuffer.java:175) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.InternalAprOutputBuffer.access$000(InternalAprOutputBuffer.java:41) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:350) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:93) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256) ~[tomcat-coyote.jar:8.0.47] at org.apache.coyote.Response.doWrite(Response.java:491) ~[tomcat-coyote.jar:8.0.47] at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:391) ~[catalina.jar:8.0.47] at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:344) ~[tomcat-util.jar:8.0.47] at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:421) ~[catalina.jar:8.0.47] at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:409) ~[catalina.jar:8.0.47] at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:97) ~[catalina.jar:8.0.47] at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122) ~[na:1.8.0_74] at magicsoft.base.io.IOUtils.copy(IOUtils.java:112) ~[bm-base-3.8.0-SNAPSHOT.jar:na] at magicsoft.base.io.IOUtils.copy(IOUtils.java:89) ~[bm-base-3.8.0-SNAPSHOT.jar:na] at magicsoft.jersey.common.UploadFiles.download(UploadFiles.java:60) ~[bm-jersey-3.8.0-SNAPSHOT.jar:na] at magicsoft.jersey.common.UploadFiles.download(UploadFiles.java:36) ~[bm-jersey-3.8.0-SNAPSHOT.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74] at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) ~[jersey-server-2.22.2.jar:na] at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.22.2.jar:na] at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [jersey-server-2.22.2.jar:na] at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [jersey-server-2.22.2.jar:na] at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [jersey-container-servlet-core-2.22.2.jar:na] at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [jersey-container-servlet-core-2.22.2.jar:na] at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [jersey-container-servlet-core-2.22.2.jar:na] at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [jersey-container-servlet-core-2.22.2.jar:na] at magicsoft.jersey.MyJerseyServlet.service(MyJerseyServlet.java:35) [bm-jersey-3.8.0-SNAPSHOT.jar:na] at magicsoft.jersey.MyJerseyServletNTSW.service(MyJerseyServletNTSW.java:64) [classes/:na] at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [jersey-container-servlet-core-2.22.2.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [catalina.jar:8.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.47] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.47] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.47] at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.1.6.jar:1.1.6] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.47] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.47] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.47] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94) [catalina.jar:8.0.47] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) [catalina.jar:8.0.47] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.47] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.47] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) [catalina.jar:8.0.47] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.47] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) [catalina.jar:8.0.47] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) [tomcat-coyote.jar:8.0.47] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) [tomcat-coyote.jar:8.0.47] at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527) [tomcat-coyote.jar:8.0.47] at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516) [tomcat-coyote.jar:8.0.47] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_74] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_74] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.47] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74] ```

struts1整合mybatis【java.io.IOException: Could not find resource configuration.xml】

[code="java"] java.io.IOException: Could not find resource configuration.xml at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:89) at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:76) at org.apache.ibatis.io.Resources.getResourceAsReader(Resources.java:134) at com.s1sm.exer.utils.MyBatisUtil.<clinit>(MyBatisUtil.java:20) at com.s1sm.exer.dao.LoginDAO.findAllUsers(LoginDAO.java:19) at com.s1sm.exer.service.impl.LoginMgrImpl.login(LoginMgrImpl.java:16) at com.s1sm.exer.web.actions.LoginAction.execute(LoginAction.java:34) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) [/code] [code="java"] package com.s1sm.exer.utils; import java.io.IOException; import java.io.Reader; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; public class MyBatisUtil { private static SqlSessionFactory sqlSessionFactory = null; static { String resource = "configuration.xml"; Reader reader = null; try { reader = Resources.getResourceAsReader(resource); } catch (IOException e) { e.printStackTrace(); } //use SqlSessionFactoryBuilder to create SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader); } public static SqlSessionFactory getSqlSessionFactory() { return sqlSessionFactory; } } [/code] 应该是路径写的不对,但是改了几次,都不行。。。。 附上我的目录结构。

java.io.IOException: End of IO Stream Read

com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read

手机端请求后台下载更新,出现错误java.io.IOException: 远程主机强迫关闭了一个现有的连接。

报错代码段 OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); response.setContentType("application/octet-stream"); toClient.write(buffer);//这一行开始报错 toClient.flush(); toClient.close(); org.apache.catalina.connector.ClientAbortException: java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) at org.apache.catalina.connector.OutputBuffer.appendByteArray(OutputBuffer.java:795) at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:724) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122) at java.io.FilterOutputStream.write(FilterOutputStream.java:97) at com.inspur.mobile.controller.MobileController.download(MobileController.java:954) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at sun.nio.ch.SocketDispatcher.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134) at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157) at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1279) at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:670) at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:450) at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:388) at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:623) at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:116) at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:225) at org.apache.coyote.Response.doWrite(Response.java:541) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:351) ... 44 more

执行jar报错 Hadoop java.io.IOException

[img=http://img.bbs.csdn.net/upload/201703/15/1489518401_142809.png][/img] Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :interface javax.xml.soap.Text hadoop jar Hadoop_Demo1.jar /user/myData/ /user/out/ 执行简单jar包 17/03/15 02:52:37 INFO client.RMProxy: Connecting to ResourceManager at s0/192.168.253.130:8032 17/03/15 02:52:37 WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this. 17/03/15 02:52:38 INFO input.FileInputFormat: Total input paths to process : 2 17/03/15 02:52:38 INFO mapreduce.JobSubmitter: number of splits:2 17/03/15 02:52:38 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1489512856623_0004 17/03/15 02:52:39 INFO impl.YarnClientImpl: Submitted application application_1489512856623_0004 17/03/15 02:52:39 INFO mapreduce.Job: The url to track the job: http://s0:8088/proxy/application_1489512856623_0004/ 17/03/15 02:52:39 INFO mapreduce.Job: Running job: job_1489512856623_0004 17/03/15 02:52:50 INFO mapreduce.Job: Job job_1489512856623_0004 running in uber mode : false 17/03/15 02:52:50 INFO mapreduce.Job: map 0% reduce 0% 17/03/15 02:55:18 INFO mapreduce.Job: map 50% reduce 0% 17/03/15 02:55:18 INFO mapreduce.Job: Task Id : attempt_1489512856623_0004_m_000001_0, Status : FAILED Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :interface javax.xml.soap.Text at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:414) at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:698) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.lang.ClassCastException: interface javax.xml.soap.Text at java.lang.Class.asSubclass(Class.java:3404) at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:887) at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:1004) at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:402) ... 9 more Container killed by the ApplicationMaster. 17/03/15 02:55:18 INFO mapreduce.Job: Task Id : attempt_1489512856623_0004_m_000000_0, Status : FAILED Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :interface javax.xml.soap.Text at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:414) at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:698) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.lang.ClassCastException: interface javax.xml.soap.Text at java.lang.Class.asSubclass(Class.java:3404) at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:887) at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:1004) at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:402) ... 9 more 17/03/15 02:55:19 INFO mapreduce.Job: map 0% reduce 0% 17/03/15 02:55:31 INFO mapreduce.Job: Task Id : attempt_1489512856623_0004_m_000000_1, Status : FAILED Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :interface javax.xml.soap.Text at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:414) at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:698) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

在利用jxls导入excel文件时报错 java.io.IOException: Stream closed?

1.在利用jxls导入excel文件时报错 java.io.IOException: Stream closed 2.代码如下 ![图片说明](https://img-ask.csdn.net/upload/201908/16/1565946326_617916.png) ![图片说明](https://img-ask.csdn.net/upload/201908/16/1565946358_986440.png) ![图片说明](https://img-ask.csdn.net/upload/201908/16/1565946388_426165.png) 还请各位帮ge忙

用idea写的MyBatis项目,测试的时候,报错:java.io.IOException: Could not find resource mybatis-config.xml 怎么回事?

用idea写的MyBatis项目,测试的时候,报错:java.io.IOException: Could not find resource mybatis-config.xml; 网上的办法都试了,配置dtd,在pom文件中加build标签,都不好使。 这是我的目录结构 ![图片说明](https://img-ask.csdn.net/upload/201912/21/1576899425_738015.png) 这是我家的build标签 ![图片说明](https://img-ask.csdn.net/upload/201912/21/1576899449_737971.png) 求 大神!

请问大家见过这个异常吗java.io.StreamCorruptedException: invalid stream header: 7371007E异常求解

代码如下 ``` package Chat; import java.io.IOException; import java.io.ObjectInputStream; import java.net.Socket; public class ClientConServerThread extends Thread{ private Socket client; public ClientConServerThread(Socket client){ this.client=client; } public Socket getClient() { return client; } public void run(){ while(true){ try { ObjectInputStream ois = new ObjectInputStream(client.getInputStream());//这里出现了异常 Message m=(Message)ois.readObject(); System.out.println(m.getCon()); } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } } } } ``` 异常如下 java.io.StreamCorruptedException: invalid stream header: 7371007E at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 00007400 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 01417400 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 0C323031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 39303033 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30313134 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 3274001C at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 54756520 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 41707220 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 32382031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 353A3436 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 3A313920 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 43535420 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 32303230 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 74000C32 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30313930 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30333031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) Process finished with exit code -1

spark shell在存运算结果到hdfs时报java.io.IOException: Not a file: hdfs://mini1:9000/spark/res

scala> sc.textFile("hdfs://mini1:9000/spark").flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).saveAsTextFile("hdfs://mini1:9000/spark/res2") 执行上面的代码出错,这个目录在hdfs下是有的,而且就算没有也会创建。还有就是我运行的代码中是保存到res2目录 ,这里为什么报没有res目录 18/11/05 19:06:44 WARN SizeEstimator: Failed to check whether UseCompressedOops is set; assuming yes java.io.IOException: Not a file: hdfs://mini1:9000/spark/res at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:320) at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:199) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:120) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:120) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:120) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:120) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.Partitioner$.defaultPartitioner(Partitioner.scala:65) at org.apache.spark.rdd.PairRDDFunctions$$anonfun$reduceByKey$3.apply(PairRDDFunctions.scala:331) at org.apache.spark.rdd.PairRDDFunctions$$anonfun$reduceByKey$3.apply(PairRDDFunctions.scala:331) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111) at org.apache.spark.rdd.RDD.withScope(RDD.scala:316) at org.apache.spark.rdd.PairRDDFunctions.reduceByKey(PairRDDFunctions.scala:330) at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:28) at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:33) at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:35) at $iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:37) at $iwC$$iwC$$iwC$$iwC.<init>(<console>:39) at $iwC$$iwC$$iwC.<init>(<console>:41) at $iwC$$iwC.<init>(<console>:43) at $iwC.<init>(<console>:45) at <init>(<console>:47) at .<init>(<console>:51) at .<clinit>(<console>) at .<init>(<console>:7) at .<clinit>(<console>) at $print(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065) at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346) at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840) at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871) at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819) at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857) at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902) at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814) at org.apache.spark.repl.SparkILoop.processLine$1(SparkILoop.scala:657) at org.apache.spark.repl.SparkILoop.innerLoop$1(SparkILoop.scala:665) at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$loop(SparkILoop.scala:670) at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:997) at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945) at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945) at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135) at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945) at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059) at org.apache.spark.repl.Main$.main(Main.scala:31) at org.apache.spark.repl.Main.main(Main.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

java.io.IOException: Broken pipe错误

![图片说明](https://img-ask.csdn.net/upload/201701/16/1484564309_220982.png) 帮忙看看,自己测服务器并发量,其他的接口跑了2000个都没有问题。这个接口跑500个就抱这种错误,每次请求数据量大约从服务器拉3Kb左右 代码的主要逻辑大体上就是从两个数据表了取数据,过滤封装之后给客户端

调用webservice出现java.io.IOException: BufferedInputStream is closed

调用服务器的webservice接口,有时会出现java.io.IOException: BufferedInputStream is closed异常,连接不上服务器。有时第一次连不上第二次再调用就连上了,这是因为什么呢?

Logstash与tcp,错误:java.io.IOException:连接被对等方重置

<div class="post-text" itemprop="text"> <p>我想在我的GolangApp中使用logstash。</p> <p>/etc/logstash/conf.d/first-pipeline.conf </p> <pre><code>input { tcp { port =&gt; 5959 codec =&gt; json } } #filter {} output { elasticsearch { hosts =&gt; [ "localhost:9200" ] } } </code></pre> <p>和用于运行logstash的命令:</p> <p>/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/first-pipeline.conf --path.settings=/etc/logstash</p> <pre><code> Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties [2018-12-09T09:11:14,984][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified [2018-12-09T09:11:14,995][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=&gt;"6.5.1"} [2018-12-09T09:11:16,968][INFO ][logstash.pipeline ] Starting pipeline {:pipeline_id=&gt;"main", "pipeline.workers"=&gt;4, "pipeline.batch.size"=&gt;125, "pipeline.batch.delay"=&gt;50} [2018-12-09T09:11:17,347][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=&gt;{:removed=&gt;[], :added=&gt;[http://localhost:9200/]}} [2018-12-09T09:11:17,356][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=&gt;http://localhost:9200/, :path=&gt;"/"} [2018-12-09T09:11:17,589][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=&gt;"http://localhost:9200/"} [2018-12-09T09:11:17,655][INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=&gt;6} [2018-12-09T09:11:17,660][WARN ][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=&gt;6} [2018-12-09T09:11:17,692][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=&gt;"LogStash::Outputs::ElasticSearch", :hosts=&gt;["//localhost:9200"]} [2018-12-09T09:11:17,730][INFO ][logstash.outputs.elasticsearch] Using mapping template from {:path=&gt;nil} [2018-12-09T09:11:17,786][INFO ][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=&gt;{"template"=&gt;"logstash-*", "version"=&gt;60001, "settings"=&gt;{"index.refresh_interval"=&gt;"5s"}, "mappings"=&gt;{"_default_"=&gt;{"dynamic_templates"=&gt;[{"message_field"=&gt;{"path_match"=&gt;"message", "match_mapping_type"=&gt;"string", "mapping"=&gt;{"type"=&gt;"text", "norms"=&gt;false}}}, {"string_fields"=&gt;{"match"=&gt;"*", "match_mapping_type"=&gt;"string", "mapping"=&gt;{"type"=&gt;"text", "norms"=&gt;false, "fields"=&gt;{"keyword"=&gt;{"type"=&gt;"keyword", "ignore_above"=&gt;256}}}}}], "properties"=&gt;{"@timestamp"=&gt;{"type"=&gt;"date"}, "@version"=&gt;{"type"=&gt;"keyword"}, "geoip"=&gt;{"dynamic"=&gt;true, "properties"=&gt;{"ip"=&gt;{"type"=&gt;"ip"}, "location"=&gt;{"type"=&gt;"geo_point"}, "latitude"=&gt;{"type"=&gt;"half_float"}, "longitude"=&gt;{"type"=&gt;"half_float"}}}}}}}} [2018-12-09T09:11:17,809][INFO ][logstash.inputs.tcp ] Automatically switching from json to json_lines codec {:plugin=&gt;"tcp"} [2018-12-09T09:11:17,862][INFO ][logstash.inputs.tcp ] Starting tcp input listener {:address=&gt;"0.0.0.0:5959", :ssl_enable=&gt;"false"} [2018-12-09T09:11:18,097][INFO ][logstash.pipeline ] Pipeline started successfully {:pipeline_id=&gt;"main", :thread=&gt;"#&lt;Thread:0x42d68f8e run&gt;"} [2018-12-09T09:11:18,157][INFO ][logstash.agent ] Pipelines running {:count=&gt;1, :running_pipelines=&gt;[:main], :non_running_pipelines=&gt;[]} [2018-12-09T09:11:18,329][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=&gt;9600} </code></pre> <p>Code in golang:</p> <pre><code>import ( "encoding/json" "fmt" "github.com/heatxsink/go-logstash" "time" ) func main() { l := logstash.New("0.0.0.0", 5959, 5) _, err := l.Connect() if err != nil { fmt.Println(err) } dataMap := map[string]int{"apple": 5, "lettuce": 7} jsonMap, _ := json.Marshal(dataMap) err = l.Writeln(string(jsonMap)) if err != nil { fmt.Println(err) } } </code></pre> <p>当我试图请求登录应用程序时,终端会显示这个错误:</p> <blockquote> <p>[2018-12-09T09:12:41,954][ERROR][logstash.inputs.tcp ] Error in Netty pipeline: java.io.IOException: Connection reset by peer</p> </blockquote> <p>所有的东西都在我的本地系统中。请帮帮我!</p> </div>

java.io.IOException: Server returned HTTP response code: 502 for URL:XXXXXX

我在从系统数据库中拿到20W张图片的url,然后下载到本地的时候部分图片下载出现了这个错误: java.io.IOException: Server returned HTTP response code: 502 for URL:XXXXX 代码: ``` public static String downLoadFromUrl(String urlStr, String fileName, String savePath) { JSONObject response = new JSONObject(); JSONArray failds = new JSONArray(); try { URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // 设置超时间为3秒 conn.setConnectTimeout(10 * 1000); // 防止屏蔽程序抓取而返回403错误 conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); // 得到输入流 InputStream inputStream = conn.getInputStream(); // 获取自己数组 byte[] getData = readInputStream(inputStream); // 文件保存位置 File saveDir = new File(savePath); if (!saveDir.exists()) { saveDir.mkdirs(); logger.info("创建文件夹:" + saveDir.exists()); } File file = new File(saveDir + File.separator + fileName); FileOutputStream fos = new FileOutputStream(file); fos.write(getData); if (fos != null) { fos.close(); } if (inputStream != null) { inputStream.close(); } return saveDir + File.separator + fileName; } catch (Exception e) { logger.error(">>>>>>image download faild,image url:" + urlStr + ",fileName:"+ fileName); failds.add(urlStr); e.printStackTrace(); } response.put("faild",failds); return response.toString(); } public InputStream getConnectionStream(String fullUrl) throws IOException { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(fullUrl); HttpResponse response = client.execute(request); InputStream is = response.getEntity().getContent(); return is; } public static byte[] readInputStream(InputStream inputStream) throws IOException { byte[] buffer = new byte[1024]; int len = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while ((len = inputStream.read(buffer)) != -1) { bos.write(buffer, 0, len); } bos.close(); return bos.toByteArray(); } ``` 下载图片就是循环调用这块代码,我应该如何优化才能避免这个错?

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

C++(数据结构与算法)78:---分而治之

一、分而治之的思想 分而治之方法与软件设计的模块化方法非常相似 分而治之通常不用于解决问题的小实例,而要解决一个问题的大实例。一般步骤为: ①把一个大实例分为两个或多个更小的实例 ②分别解决每个小实例 ③把这些小实例的解组合成原始大实例的解 二、实际应用之找出假币 问题描述 一个袋子有16个硬币,其中只有一个是假币,这个假币比其他的真币重量轻(其他所有真币的重量都是相同的)...

springboot+jwt实现token登陆权限认证

一 前言 此篇文章的内容也是学习不久,终于到周末有时间码一篇文章分享知识追寻者的粉丝们,学完本篇文章,读者将对token类的登陆认证流程有个全面的了解,可以动态搭建自己的登陆认证过程;对小项目而已是个轻量级的认证机制,符合开发需求;更多精彩原创内容关注公主号知识追寻者,读者的肯定,就是对作者的创作的最大支持; 二 jwt实现登陆认证流程 用户使用账号和面发出post请求 服务器接受到请求后使用私...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

早上躺尸,晚上干活:硅谷科技公司这么流行迟到?

硅谷科技公司上班时间OPEN早已不是什么新鲜事,早九晚五是常态,但有很多企业由于不打卡,员工们10点、11点才“姗姗来迟”的情况也屡见不鲜。 这种灵活的考勤制度为人羡慕,甚至近年来,国内某些互联网企业也纷纷效仿。不过,硅谷普遍弹性的上班制度是怎么由来的呢?这种“流行性迟到”真的有那么轻松、悠哉吗? 《动态规划专题班》 课程试听内容: 动态规划的解题要领 动态规划三大类 求最值/计数/可行性 常...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

立即提问
相关内容推荐