We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi,
I am trying to make a data store and I want to ask the user the question if he wants to use an existing file or he wants to create a new one, for that I have to read the filenames and print him the existing ones, and I don't know how to do that, I already had a look at another contribution but that didn't help me (I am not the best programmer)
Answers
import java.io.File;
File folder; String [] filenames;
void setup() { java.io.File folder = new java.io.File(dataPath(" ")); }
void draw() { filenames = folder.list(); println(filenames.length + ".properties.ser");
for(int i = 0; i <= filenames.length; i++) { println(filenames[i]); } }
@Skyfreak== try this (but there are a lot of other ways); getName() is (for me) the solution::
I'll try it out thanks ;-)
okay, got a better idea but thanks
are you sure that your files are in the data folder of your sketch; i have tested my code & it runs...
ah, i see , error with copy & paste, i forgotten string[] resultat!!!! so===
import
. It's already done by Processing! :PP.S.: If you also wanna filter by file extensions, pass an instance of FilenameFilter as argument for list():
@goToLoop== - thanks! i always imported File without thinking! - i dont know the printArray() method you use (kind of ArraysToString() i think?) - & cannot find it in reference
https://processing.org/reference/printArray_.html
@goToLoop== ok; added in2.0: i used the 1.5.1 reference and found nothing of course best wishes!
P2 added printArray() b/c println() somehow lost its original way of displaying arrays.
In other words, P2's printArray() behaves exactly as P1's println() for arrays! :-B
See How to format code and text, avoid posting code in screenshots, they are barely readable, cannot be searched nor copy & pasted in the PDE..