Thu Jul 30, 2009 12:21 pm
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.channels.FileChannel;
public class testsett {
void copy()
{
try{
File inputFile = new File( "c:\\winnt\\system32\\testall.dll");
URL copyurl;
InputStream outputFile;
copyurl=new URL("http://<server ipaddress>:8080/Samples/testall.dll");
outputFile=copyurl.openStream();
FileOutputStream out = new FileOutputStream(inputFile);
int c;
while ((c = outputFile.read()) != -1)
out.write(c);
outputFile.close();
out.close();
}catch(Exception e){
System.out.println("Failed to Copy File from server");
e.printStackTrace();
}
}
void copyprop()
{
try{
File inputFile = new File( "c:\\winnt\\system32\\propert.properties");
URL copyurl;
InputStream outputFile;
copyurl=new URL("http://<server ipaddress>:8080/Samples/propert.properties");
outputFile=copyurl.openStream();
FileOutputStream out = new FileOutputStream(inputFile);
int c;
while ((c = outputFile.read()) != -1)
out.write(c);
outputFile.close();
out.close();
}catch(Exception e){
System.out.println("Failed to Copy File from server");
e.printStackTrace();
}
}
public static void main(String args[]) throws IOException
{
testsett ts = new testsett();
ts.copyprop();
ts.copy();
}
}
Fri Jul 31, 2009 9:28 am
System.getProperty("user.home" );
Fri Jul 31, 2009 12:53 pm
<%@ page language="java" %>
<html>
<head>
<title>Welcome JSP-Applet Page</title>
</head>
<body>
<applet code="testapp.class" width="1000" height="190">
<param name="path" value=<%="\""+getServletContext().getRealPath("/")+"\""%> />
<param name="file" value=<%="testall.dll"%> />
<param name="prop" value=<%="propert.properties"%> />
</applet>
</body>
</html>
String path = null;
String file = null;
String prop = null;
public void init()
{
path = getParameter("path");
file = getParameter("file");
prop = getParameter("prop");
try{
File inputFile = new File( "c:\\winnt\\system32\\propert.properties");
URL copyurl;
InputStream outputFile;
copyurl=new URL(getCodeBase(),prop);
outputFile=copyurl.openStream();
FileOutputStream out = new FileOutputStream(inputFile);
int c;
while ((c = outputFile.read()) != -1)
out.write(c);
outputFile.close();
out.close();
}catch(Exception e){
System.out.println("Failed to Copy properties from server");
e.printStackTrace();
}
try{
File inputFile = new File( "c:\\winnt\\testall.dll");
URL copyurl;
InputStream outputFile;
copyurl=new URL(getCodeBase(),file);
outputFile=copyurl.openStream();
FileOutputStream out = new FileOutputStream(inputFile);
int c;
while ((c = outputFile.read()) != -1)
out.write(c);
outputFile.close();
out.close();
}catch(Exception e){
System.out.println("Failed to Copy dll from server");
e.printStackTrace();
}
Fri Jul 31, 2009 1:08 pm
Sun Aug 02, 2009 9:08 am
Thu Jan 24, 2013 9:53 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.