- Stream Programming with .NET»
- StreamReader and StreamWriter
StreamReader and StreamWriter
To handle text streams more easily, the .NET language has the StreamReader and StreamWriter classes. But these class do NOT inherit from Stream, they encapsulate it.
The StreamReader and StreamWriter classes derive respectively from TextReader and TextWriter which are designed to ease reading or writing text oriented streams.
Just like Stream, TextReader and TextWriter are abstract classes which exposes functionality that are implemented by it's inheritor. As all class implementing TextReader or TextWriter behave in the same way, we will consentrate on StreamReader and StreamWriter.
You can instanciate a StreamReader or a StreamWriter by passing a file name or a Stream to the constructor. Due to the fact that these classes are specially designed to handle texts, you can also construct an instance by passing it an encoding. By default, StreamReader and StreamWriter use the unicode encoding.
The following tables describe the properties and methods of those classes:
StreamReader | |
---|---|
Object -> TextReader -> StreamReader | |
using System.IO; | |
Methods | |
Prototype | Description |
int Peek() | Return the next caracter in the stream. Return -1 if no more caracter available. |
int Read () | Same as Peek but DO remove the caracter from the stream. |
string ReadLine() | Read the next line. A line is built of caracters and is ended by \n or \r. ReadLine return null if no more data is available |
string ReadToEnd() | Read the whole file |
StreamWriter | ||
---|---|---|
Object -> TextWriter -> StreamWriter | ||
using System.IO; | ||
Properties | ||
Name | Type | Description |
AutoFlush | bool | In the case of a bufferized I/O, if AutoFlush is true, a write will be automatically affect the stream, not only the buffer |
NewLine | string | Caracters of line ending. By default those caracters are \r\n |
Methods | ||
Prototype | Description | |
void Flush() | Force writing on the stream | |
void Write( args ) | Write in the stream. args may be of any type. | |
void WriteLine( args ) | Perform the same operation as Write but a new line is appended to the stream. This new line correspond to the string specified for the NewLine property. |
The following example is divided in two parts. In the first part, a file is read using FileStream's methods; in the second part, the same file is read using a StreamReader
org.xwiki.rendering.macro.MacroExecutionException: Failed to highlight content at org.xwiki.rendering.internal.macro.code.CodeMacro.parseContent(CodeMacro.java:121) at org.xwiki.rendering.internal.macro.code.CodeMacro.parseContent(CodeMacro.java:57) at org.xwiki.rendering.macro.box.AbstractBoxMacro.execute(AbstractBoxMacro.java:141) at org.xwiki.rendering.macro.box.AbstractBoxMacro.execute(AbstractBoxMacro.java:53) at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transformOnce(MacroTransformation.java:191) at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:132) at org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:87) at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:252) at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:125) at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:55) at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:80) at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:38) at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:113) at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:50) at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:67) at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:41) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:993) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:972) at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1003) at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:603) at sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280) at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:567) at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342) at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228) at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:187) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:105) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1740) at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1659) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1627) at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:918) at sun.reflect.GeneratedMethodAccessor128.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:216) at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:311) at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:230) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342) at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228) at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:187) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:105) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1740) at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1659) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:166) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:304) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:129) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:121) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:144) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:203) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:181) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:66) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 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:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1504) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1460) 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: org.xwiki.rendering.parser.ParseException: Failed to highlight code at org.xwiki.rendering.internal.parser.pygments.PygmentsParser.highlight(PygmentsParser.java:183) at org.xwiki.rendering.internal.macro.code.CodeMacro.highlight(CodeMacro.java:168) at org.xwiki.rendering.internal.macro.code.CodeMacro.parseContent(CodeMacro.java:118) ... 116 more Caused by: javax.script.ScriptException: java.lang.StringIndexOutOfBoundsException: java.lang.StringIndexOutOfBoundsException: String index out of range: 3 in <script> at line number 30 at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202) at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42) at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31) at org.xwiki.rendering.internal.parser.pygments.PygmentsParser.highlight(PygmentsParser.java:215) at org.xwiki.rendering.internal.parser.pygments.PygmentsParser.highlight(PygmentsParser.java:181) ... 118 more Caused by: Traceback (most recent call last): File "<script>", line 30, in <module> File "<script>", line 30, in <module> File "__pyclasspath__/pygments/lexers/__init__.py", line 74, in get_lexer_by_name File "__pyclasspath__/pygments/lexers/__init__.py", line 32, in _load_lexers File "__pyclasspath__/pygments/lexers/dotnet.py", line 20, in <module> File "__pyclasspath__/pygments/lexers/web.py", line 13, in <module> File "/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/jython-standalone-2.5.4-rc1.jar/Lib/copy.py", line 59, in <module> File "/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/jython-standalone-2.5.4-rc1.jar/Lib/copy.py", line 59, in <module> at java.lang.String.charAt(String.java:658) at org.apache.catalina.loader.WebappClassLoaderBase.filter(WebappClassLoaderBase.java:2802) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1254) at java.lang.ClassLoader.loadClass(ClassLoader.java:411) at java.lang.ClassLoader.loadClass(ClassLoader.java:411) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.python.core.Py.loadAndInitClass(Py.java:909) at org.python.core.Py.findClassInternal(Py.java:844) at org.python.core.Py.findClassEx(Py.java:895) at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133) at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28) at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122) at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137) at org.python.core.PyObject.__findattr__(PyObject.java:863) at org.python.core.packagecache.PackageManager.lookupName(PackageManager.java:136) at org.python.core.JavaImporter.find_module(JavaImporter.java:39) at org.python.core.JavaImporter.find_module(JavaImporter.java:25) at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) java.lang.StringIndexOutOfBoundsException: java.lang.StringIndexOutOfBoundsException: String index out of range: 3 at org.python.core.Py.JavaError(Py.java:495) at org.python.core.Py.JavaError(Py.java:488) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188) at org.python.core.PyObject.__call__(PyObject.java:345) at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220) at org.python.core.PyMethod.__call__(PyMethod.java:211) at org.python.core.PyMethod.__call__(PyMethod.java:201) at org.python.core.PyMethod.__call__(PyMethod.java:196) at org.python.core.imp.find_module(imp.java:469) at org.python.core.imp.import_next(imp.java:718) at org.python.core.imp.import_module_level(imp.java:827) at org.python.core.imp.importName(imp.java:917) at org.python.core.ImportFunction.__call__(__builtin__.java:1220) at org.python.core.PyObject.__call__(PyObject.java:357) at org.python.core.__builtin__.__import__(__builtin__.java:1173) at org.python.core.imp.importFromAs(imp.java:1011) at org.python.core.imp.importFrom(imp.java:987) at copy$py.f$0(/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/jython-standalone-2.5.4-rc1.jar/Lib/copy.py:414) at copy$py.call_function(/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/jython-standalone-2.5.4-rc1.jar/Lib/copy.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:391) at org.python.core.util.importer.importer_load_module(importer.java:109) at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161) at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source) at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47) at org.python.core.imp.loadFromLoader(imp.java:518) at org.python.core.imp.find_module(imp.java:472) at org.python.core.imp.import_next(imp.java:718) at org.python.core.imp.import_first(imp.java:748) at org.python.core.imp.import_module_level(imp.java:837) at org.python.core.imp.importName(imp.java:917) at org.python.core.ImportFunction.__call__(__builtin__.java:1220) at org.python.core.PyObject.__call__(PyObject.java:357) at org.python.core.__builtin__.__import__(__builtin__.java:1173) at org.python.core.imp.importOne(imp.java:936) at pygments.lexers.web$py.f$0(__pyclasspath__/pygments/lexers/web.py:3353) at pygments.lexers.web$py.call_function(__pyclasspath__/pygments/lexers/web.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:391) at org.python.core.util.importer.importer_load_module(importer.java:109) at org.python.core.ClasspathPyImporter.ClasspathPyImporter_load_module(ClasspathPyImporter.java:63) at org.python.core.ClasspathPyImporter$ClasspathPyImporter_load_module_exposer.__call__(Unknown Source) at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47) at org.python.core.imp.loadFromLoader(imp.java:518) at org.python.core.imp.find_module(imp.java:472) at org.python.core.PyModule.impAttr(PyModule.java:100) at org.python.core.imp.import_next(imp.java:720) at org.python.core.imp.import_logic(imp.java:782) at org.python.core.imp.import_module_level(imp.java:842) at org.python.core.imp.importName(imp.java:917) at org.python.core.ImportFunction.__call__(__builtin__.java:1220) at org.python.core.PyObject.__call__(PyObject.java:357) at org.python.core.__builtin__.__import__(__builtin__.java:1173) at org.python.core.imp.importFromAs(imp.java:1011) at org.python.core.imp.importFrom(imp.java:987) at pygments.lexers.dotnet$py.f$0(__pyclasspath__/pygments/lexers/dotnet.py:530) at pygments.lexers.dotnet$py.call_function(__pyclasspath__/pygments/lexers/dotnet.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:391) at org.python.core.util.importer.importer_load_module(importer.java:109) at org.python.core.ClasspathPyImporter.ClasspathPyImporter_load_module(ClasspathPyImporter.java:63) at org.python.core.ClasspathPyImporter$ClasspathPyImporter_load_module_exposer.__call__(Unknown Source) at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47) at org.python.core.imp.loadFromLoader(imp.java:518) at org.python.core.imp.find_module(imp.java:472) at org.python.core.PyModule.impAttr(PyModule.java:100) at org.python.core.imp.import_next(imp.java:720) at org.python.core.imp.import_logic(imp.java:782) at org.python.core.imp.import_module_level(imp.java:842) at org.python.core.imp.importName(imp.java:917) at org.python.core.ImportFunction.__call__(__builtin__.java:1220) at org.python.core.PyObject.__call__(PyObject.java:441) at org.python.core.PyObject.__call__(PyObject.java:447) at pygments.lexers$py._load_lexers$1(__pyclasspath__/pygments/lexers/__init__.py:33) at pygments.lexers$py.call_function(__pyclasspath__/pygments/lexers/__init__.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyBaseCode.call(PyBaseCode.java:134) at org.python.core.PyFunction.__call__(PyFunction.java:317) at pygments.lexers$py.get_lexer_by_name$4(__pyclasspath__/pygments/lexers/__init__.py:80) at pygments.lexers$py.call_function(__pyclasspath__/pygments/lexers/__init__.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyBaseCode.call(PyBaseCode.java:301) at org.python.core.PyFunction.function___call__(PyFunction.java:376) at org.python.core.PyFunction.__call__(PyFunction.java:371) at org.python.pycode._pyx105.f$0(<script>:52) at org.python.pycode._pyx105.call_function(<script>) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1275) at org.python.core.__builtin__.eval(__builtin__.java:484) at org.python.core.__builtin__.eval(__builtin__.java:488) at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:198) at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:40) ... 121 more Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 3 at java.lang.String.charAt(String.java:658) at org.apache.catalina.loader.WebappClassLoaderBase.filter(WebappClassLoaderBase.java:2802) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1254) at java.lang.ClassLoader.loadClass(ClassLoader.java:411) at java.lang.ClassLoader.loadClass(ClassLoader.java:411) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.python.core.Py.loadAndInitClass(Py.java:909) at org.python.core.Py.findClassInternal(Py.java:844) at org.python.core.Py.findClassEx(Py.java:895) at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133) at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28) at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122) at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137) at org.python.core.PyObject.__findattr__(PyObject.java:863) at org.python.core.packagecache.PackageManager.lookupName(PackageManager.java:136) at org.python.core.JavaImporter.find_module(JavaImporter.java:39) at org.python.core.JavaImporter.find_module(JavaImporter.java:25) at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186) ... 214 more
Advantages | Drawbacks |
---|---|
Easy text file access | Do not inherit from Stream |
Easy encoding management through Encoding class | |
Can be constructed around any Stream object, thus allowing binary reading/writing on any streaming source |
Related articles: