简体   繁体   English

为什么java.io.File的prefixLength是瞬态的?

[英]Why is java.io.File's prefixLength transient?

java.io.File 's prefixLength can be used as an identifier for what type of path the File contains. java.io.FileprefixLength可用作File包含的路径类型的标识符。 Why is the prefixLength field transient ? 为什么prefixLength字段是transient

transient is used to indicate the field will be ignored by the standard java serialisation process. transient用于指示标准Java序列化过程将忽略该字段。 In this case it is handled explicitly by the readObject() method instead. 在这种情况下,它由readObject()方法显式处理。 This, and path are both handled in the same way. 这和path都以相同的方式处理。

This is so that when objects are serialised between JVMs running on different platforms (Windows, Linux, etc) the path can be normalised using the platforms file system. 这样,当在不同平台(Windows,Linux等)上运行的JVM之间对对象进行序列化时,可以使用平台文件系统对path进行规范化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM