How can write and read arraylist to a file? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How can write and read arraylist to a file?

how can write data to a file and read data from that? which format of file better to use to make file protected? make an simple example please.

14th May 2017, 6:03 PM
hamid
hamid - avatar
6 Respuestas
+ 1
I think this should help you: https://code.sololearn.com/cyN739LetgkU/#java What do you mean by "make the file protected"?
14th May 2017, 6:49 PM
nouseforname
nouseforname - avatar
0
protected: dont editable
15th May 2017, 2:04 AM
hamid
hamid - avatar
0
Your question is how to read/write a file from/to an ArrayList. This is already answered. "Read-Only" for your application or for any user (which is easy to be changed by user anyway)? You can play arround with: File f = new File(sFile); f.setExecutable(false); f.setReadable(false); f.setWritable(false);
15th May 2017, 3:51 AM
nouseforname
nouseforname - avatar
0
think we have an arraylist, we want save data to that, and read this data from this arraylist, how write this code?
15th May 2017, 7:44 AM
hamid
hamid - avatar
0
This i already answered down below with a sample program
15th May 2017, 7:48 AM
nouseforname
nouseforname - avatar
0
There are a lot of stream types you can try, there is a lot of information on the web. I recommend inStream and outStram. Just make sure you know how to use them well as they can make a lot of errors when used not correctly. If you need help detecting those errors you try using some softwares such as checkmarx or others. Anyway, good luck with it! Ben.
26th May 2017, 2:18 PM
Ben hart