@All,
The problem has been solved. The code can uploads the original file
into FTP server. But, I found that the size of original file and the
uploaded file were different. You can see the files at
www.artikelilmiah.com/twinfiles.zip . If you open these files with hex
editor, you'll find several 0x0d(s) inside the bytes. How come ?
Here is my code :
@Action public void uploadDICOM() {
setVisible(false);
if (processingBox == null) {
JFrame mainFrame = Main.getApplication().getMainFrame();
processingBox = new Processing(mainFrame);
processingBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(processingBox);
FTPClient ftp = new FTPClient();
try
{
String server = "127.0.0.1";
String username="dicom";
String password="dicom";
int reply;
ftp.connect(server);
ftp.login(username, password);
reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
setVisible(false);
if (uploadDICOMBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
uploadDICOMBox = new UploadFailed(mainFrame);
uploadDICOMBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(uploadDICOMBox);
}
File inFile = new File("D:\\NetBeanProject\\ECGTerminal3\
\src\\ecgterminal3\\ToBeUploaded.txt");
BufferedReader br = new BufferedReader(new
FileReader(inFile));
String text2 = null;
while ((text2 = br.readLine()) != null)
{
String[] words = text2.split(";");
try {
FileInputStream inputstream = new
FileInputStream(words[0]);
ftp.storeFile(words[1],inputstream);
inputstream.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
br.close();
ftp.logout();
ftp.disconnect();
processingBox.setVisible(false);
setVisible(false);
if (uploadDICOMBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
uploadDICOMBox = new UploadDone(mainFrame);
uploadDICOMBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(uploadDICOMBox);
}
catch(IOException e)
{
processingBox.setVisible(false);
setVisible(false);
if (uploadDICOMBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
uploadDICOMBox = new UploadFailed(mainFrame);
uploadDICOMBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(uploadDICOMBox);
}
}