Exception Information
java.io.IOException: No such file or directoryat java.io.FileOutputStream.writeBytes(Native Method)at java.io.FileOutputStream.write(FileOutputStream.java:247)at com.nstc.framework.web.util.jsloader.JsFileModelMgrTest.testGetJs(JsFileModelMgrTest.java:53)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:585)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
Cause of exception
There are too many such exceptions. This is only one of the reasons. When a file stream instance is created and filechannel is used, the file content is operated through NiO, disable filechannel after the operation is complete. If you try to write it here, an error will be thrown.
Code
@Test public void testGetJs() { jfmmInst.doLoaderJs(); FileOutputStream fous = null; FileChannel fileChannel = null; try { fous = new FileOutputStream(testFile, false); fileChannel = fous.getChannel(); jfmmInst.doRestoreIO("ExtExtension", fileChannel); fileChannel.close(); fous.write("HelloWorld\n".getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { if (fous != null) { try { fous.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } }