直接上代码
public static void main(String[] args) {
// 创建输出文件 (这是我们公司创建file文件的方式,公司自己的依赖)
File outputFile = Take.Subset().getTemporaryFile();
try (
FileWriter fileWriter = new FileWriter(outputFile);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)
) {
String[] lines = {"第一行内容", "第二行内容", "第三行内容"}; // 你的内容数组
for (String line : lines) {
bufferedWriter.write(line);
bufferedWriter.newLine(); // 换行
}
} catch (IOException e) {
e.printStackTrace();
}
CommonUtility.pushFtp(req,"/INTERFACE/GALILEO/",outputFile);
}
public class CommonUtility {
public static void pushFtp(MapMessage params, String filePath,File tmpFile) throws Exception {
MapMessage map = DBUtils.getOne(null, "KA0027.M_DICTIONARY.SEL013").getMapMessage();
//文件名称
String filename = map.getString("value");
File targetFile = new File("C:\\111", filename);
// 使用FileOutputStream将源文件内容写入目标文件
try (FileOutputStream fos = new FileOutputStream(targetFile);
FileInputStream fis = new FileInputStream(tmpFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead);
}
fos.flush();
}
}
}