1
원격 파일에 문자열 컨텐츠를 배치해야합니다.문자열을 Java를 사용하는 원격 컴퓨터의 파일로 전송
적으로는, 내가이 지역에서 파일을 생성 한 다음 원격 컴퓨터로 해당 파일을 전송하는 데 사용됩니다.
다음은 내가 원격으로 파일을 복사하는 데 사용되는 코드입니다.
ChannelSftp sftpChannel = (ChannelSftp) channel;
File file = new File(filePathWithName);//To read the file in local machine
try {
sftpChannel.cd(location);//Remote location
//Transferring the file to RemoteLocation.
sftpChannel.put(new FileInputStream(file), file.getName());//.(Here I don't want read a file.) //Instead I want copy a content which is in string variable, something like below two lines, to the remote location.
String content = "abcdefg";
sftpChannel.put(content,"someFileName")
} catch (SftpException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
sftpChannel.exit();
는 참조 또는 문서가 원격 컴퓨터에서 같은를 만들 현지에서 파일을 읽기가 극복하는 것입니다.
고마워요