output.write(errorMessage.getBytes());
}
}
catch (Exception e) {
// thrown if cannot instantiate a File object
System.out.println(e.toString() );
}
finally {
if (fis!=null)
fis.close();
}
}
}
③发送请求的文件到web浏览器
package http;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class InputtoFilr {
public void saveinFile() {
try {
PrintStream ps = new PrintStream(new
FileOutputStream("D:\\test.txt"));
System.setOut(ps);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}