实际上我需要将文件从本地传输到FTP服务器。
ComPtr<IMouseCapabilities> caps;
HRESULT hr = RoActivateInstance(HStringReference(RuntimeClass_Windows_Devices_Input_MouseCapabilities).Get(), &caps);
这里输入流得到a.xt&amp;来自test-file文件夹的b.txt文件(它位于项目src / main / resource中)
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("META-INF/spring/integration/FtpOutboundChannelAdapterSample-context.xml");
MessageChannel ftpChannel = ctx.getBean("ftpChannel", MessageChannel.class);
final File baseFolder = new File("target" + File.separator + "toSend");
baseFolder.mkdirs();
final File fileToSendA = new File(baseFolder, "a.txt");
final File fileToSendB = new File(baseFolder, "b.txt");
这些都很有效。
但我的问题是如何从本地目录获取文件&amp;我试过了:
final InputStream inputStreamA = FtpOutboundChannelAdapterSample.class.getResourceAsStream("/test-files/a.txt");
final InputStream inputStreamB = FtpOutboundChannelAdapterSample.class.getResourceAsStream("/test-files/b.txt");
FileUtils.copyInputStreamToFile(inputStreamA, fileToSendA);
FileUtils.copyInputStreamToFile(inputStreamB, fileToSendB);
final Message<File> messageA = MessageBuilder.withPayload(fileToSendA).build();
final Message<File> messageB = MessageBuilder.withPayload(fileToSendB).build();
ftpChannel.send(messageA);
ftpChannel.send(messageB);
Thread.sleep(2000);
System.out.println("Successfully transfered file 'a.txt' and 'b.txt' to a remote FTP location.");
ctx.close();
我正在final InputStream inputStreamA = FtpOutboundChannelAdapterSample.class.getResourceAsStream("D:/Test-download/a.txt");
。
我的xml是
NullPointerException