Hi vsubram2,
After including your function and calling it. I got a
sun.net.ftp.FtpLoginExcept
Before including i can read the xml on the webpage. Anyway to solve this?
Thanks in advance.
Main Topics
Browse All TopicsHi all,
I have a xml which i've downloaded from a FTP server.
I would like to convert the InputStream to a File so i could upload to another FTP server as a xml file.
I'm using Javazoom upload.
This is the code i've done so far to read the xml:
response.setContentType("t
URL url = new URL("ftp://user:password@F
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // to download
BufferedInputStream input= new BufferedInputStream(is);
int readBytes=0;
while((readBytes=input.rea
%> <%out.write(readBytes);%><
}
Thanks in advance. I'll be back tomorrow to view it.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi vsubram2,
After including your function and calling it. I got a
sun.net.ftp.FtpLoginExcept
Before including i can read the xml on the webpage. Anyway to solve this?
Thanks in advance.
I dont think ,the sun.net.ftp.FtpLoginExcept
since the fn is no way related with the FTP,it is just reading the inputstream from the url and creates a file.
response.setContentType("t
URL url = new URL("ftp://user:password@F
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // to download
createFile(is,"file1.xml")
did u change the jdk version .
seems ,it s due to diff cause.
http://www.jdom.org/piperm
Hi vsubram2,
With the code below, i had no problems viewing the xml in jsp, only when i try to call the function then the problem arise.
The file i try to write in don't seems to get affected by my write.
i did not change the jdk version. Is there something else that trigger the error?
<%!
public static void createFile(InputStream io, String fileName) throws IOException {
FileOutputStream fos = new FileOutputStream(fileName)
byte[] buf = new byte[256];
int read = 0;
while ((read = io.read(buf)) > 0) {
fos.write(buf, 0, read);
}
}
%>
<%
response.setContentType("t
String urlAdd = "ftp://user:password@FTP.a
int readBytes=0;
String newXML = "newfile.xml";
try{
FileWriter fw = new FileWriter(newXML);
URL url= new URL(urlAdd);
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // to download
//createFile(is,newXML); =====> the call function
BufferedReader br = new BufferedReader(new InputStreamReader(is));
fw.flush();
while((readBytes=br.read()
fw.write(br.readLine()+"\r
out.println(br.readLine()+
}
}catch(Exception e){
out.print(e);
}
%>
Thanks in advance.
PS. I would be back to check 5 days later.
Happy new year folks.
sorry for jumping in. this function should be OK:
public static void createFile(InputStream in, String fileName) throws Exception
{
try
{
FileOutputStream outStream = new FileOutputStream(fileName)
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
int ch = 0;
while ((ch = in.read()) >= 0)
{
byteArrayOS.write(ch);
}
byteArrayOS.writeTo( outStream ); //converted to ASCII data, not binary
byteArrayOS.flush();
outStream.flush();
outStream.close();
}
catch (Exception ie)
{
ie.printStackTrace();
}
}
Business Accounts
Answer for Membership
by: vsubram2Posted on 2006-12-27 at 22:16:22ID: 18206560
<%! ; ext/xml"); TP.address .COM/file. xml"); ;
public static void createFile(InputStream io, String fileName) throws IOException {
FileOutputStream fos = new FileOutputStream(fileName)
byte[] buf = new byte[256];
int read = 0;
while ((read = io.read(buf)) > 0) {
fos.write(buf, 0, read);
}
}
%>
response.setContentType("t
URL url = new URL("ftp://user:password@F
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // to download
createFile(is,"file1.xml")