Applications running in a cloud platform run in an isolated container with an ephemeral local file system. If, for an example, an application crashes, the file system is discarded and a new file system is allocated for the new container instance. Therefore, you can use the local file system only for creating temporary files or for keeping temporary caches, not for storing persistent information. To store persistent information, use a relational or NoSQL database or other external service.
This rule flags Java code that references the following classes, constructors, and methods that are used for writing files.
java.io.FileOutputStreamjava.io.FileWriternew java.io.PrintWriter(java.io.File)new java.io.PrintWriter(java.io.File, java.lang.String)new java.io.PrintWriter(java.lang.String)new java.io.PrintWriter(java.lang.String, java.lang.String)java.io.RandomAccessFile
writewriteBooleanwriteBytewriteByteswriteCharwriteCharswriteDoublewriteFloatwriteIntwriteLongwriteShortwriteUTFsetLengthjava.nio.file.Files:
copycreateDirectoriescreateFilemovenewBufferedWriternewByteChannelwriteorg.apache.commons.io.FileUtils
copyDirectorycopyDirectoryToDirectorycopyFilecopyFileToDirectorycopyInputStreamToFilecopyToFilecopyURLToFilemoveDirectorymoveDirectoryToDirectorymoveFilemoveFileToDirectorymoveToDirectorywritewriteByteArrayToFilewriteLineswriteStringToFileFor more information, see the IBM Cloud databases services available.