In a nutshell i'm working with a program that uses JSCH and xstream to zip a file, and send it to a remote linux server. I'm using static folders, but when i send a file with the same name as one in the folder it will overwrite the exhisting file. I don't want this to happen. I can run pre and post scripts before and after the file is sent. How can i eliminate this, i was thinking returning a file with the list of files using ls and somehow storing that in a file. I'm curious of how someone else would do it as i'm trying to find the most efficient way.

Thanks

Is it the server that blindly writes the file? Can you get a list of files on the server so you know what files exist?

The file is being written on my side in the java program, then just being sftp over to the server. I tried to run an ls command on the folder, and save the output in the logfile, but the logfile included several other pieces of info like time and date. Idealy i'd like just a txt file list of the names so i can fetch that file, then compare my filename to all the names within it.

I actually just figured out how to list the filenames into a text file, and i can send that file back. Now the question is how do i compare the name of the file im sending to the names in the text file?

Open the text file and read its contents into a String array or arraylist that you can search.

Gotcha, that's what i was thinking. I just got it working, i fetched the file from the server, then used the buffer to read it into the program, then compared the contents of the file, to the string.

Thanks for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.