Rev 1372 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/**This is a simple class that can load, save, and removefiles from the native file system. It is needed by Safari and Operafor the dojo.storage.browser.FileStorageProvider, since both ofthese platforms have no native way to talk to the file systemfor file:// URLs. Safari supports LiveConnect, but only for talkingto an applet, not for generic scripting by JavaScript, so we musthave an applet.@author Brad Neuberg, bkn3@columbia.edu*/import java.io.*;import java.util.*;public class DojoFileStorageProvider{public String load(String filePath)throws IOException, FileNotFoundException{StringBuffer results = new StringBuffer();BufferedReader reader = new BufferedReader(new FileReader(filePath));String line = null;while((line = reader.readLine()) != null){results.append(line);}reader.close();return results.toString();}public void save(String filePath, String content)throws IOException, FileNotFoundException{PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(filePath, false)));writer.print(content);writer.close();}public void remove(String filePath)throws IOException, FileNotFoundException{File f = new File(filePath);if(f.exists() == false || f.isDirectory()){return;}if(f.exists() && f.isFile()){f.delete();}}}