Reason: Domino exported attachments are sometimes HTM pages, where the reference path to pictures and so on contains more "$FILE/"
Requirements: Replace "$FILE/" in the HTM page in the specified folder as empty
Scenario: Work with Java programs to manipulate local folders and files
The source code is as follows:
Import Java.io.BufferedReader;
Import Java.io.File;
Import Java.io.FileInputStream;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Java.io.InputStreamReader;
public class Changefolderfiles {
public static int count = 0;
public static void Main (string[] args) {
String Path = "c://test";//---folder path to operate
Changefile (path);
System.out.println ("Change +count+"). ");
}
public static void Changefile (String tmpfilepath) {
File Tmpfile = new file (Tmpfilepath);
if (Tmpfile.isdirectory ()) {
file[] files = tmpfile.listfiles ();
for (int i = 0; i < files.length; i++) {
Changefile (Files[i].getpath ());
}
else if (Tmpfile.isfile ()) {
FileInputStream fin = null;
FileOutputStream fout = null;
String filename = Tmpfile.getname ();
try {
if (Filename.substring (Filename.length ()-4). Equalsignorecase (". HTM ")) {
Fout = new FileOutputStream (New File (Tmpfile.getparentfile (). GetPath () + "//" + Tmpfile.getparentfile (). GetName () + ". HTM "));
Fin = new FileInputStream (tmpfile);
BufferedReader br = new BufferedReader (new InputStreamReader (Fin));
String strline = "";
while ((strline = Br.readline ())!= null) {
if (Strline.indexof ("$FILE/") >-1) {
strline = Strline.replace ("$FILE/", "");
count++;
}
Fout.write ((strline + "/r/n"). GetBytes ());
}
}
catch (Exception e) {
E.printstacktrace ();
finally {
try {
if (Fin!= null) {
Fin.close ();
}
if (fout!= null) {
Fout.close ();
}
catch (IOException ex) {
Ex.printstacktrace ();
}
}
} else {
System.out.println ("There is a problem with the file path provided.) ");
}
}
}
After testing, can meet the needs of normal.