Copying Files in Java
How can I code in Java the copying of a file from one directory to another. I am trying to copy a Database from one folder to another and I do not want to use streams because this will read in characters or bytes but the Database is made up of tables. I thought there might be a method called 'copy' in the Java API, but I cannot find it anywhere.
The closest I have got to the solution is the use of renameTo method in the Java API. However this copies the file but also removes it from the original location (like cut and paste). Is there a way of using a method similar to that so I get the file in both locations?
Thanks in advance.
Here's a utility class I wrote specifically for that purpose. It contains a method for copying files, and one for copying entire directories(including sub-directories).
I use this mostly to move around mySql databases.
http://www.auburn.edu/~bradfje/FileUtil.txt
1. copyDirectory(String source, String destination)
source is the directory to be copied, destination is what you want the new diretory to be called. Use absolute file names.
2.copyFile(String source, String destination)
same remarks as above.
Similar Messages
-
i copy a picture from one location to another using FileInpustStream method..
is there any better way to copy file faster, cause using this way takes way to much time to copy a picture file
try
FileInputStream r=new FileInputStream(new File(source));
FileOutputStream w=new FileOutputStream(new File(destination));
int only;
while((only=r.read())!=-1)
w.write(only);
r.close();
w.close();
catch(Exception er)
System.out.println(er);
}Here's the difinitive tutorial on java io performance tweaks:
http://java.sun.com/developer/technicalArticles/Programming/PerfTuning/
Based on the examples there in (plus some of my own illconceived numbknuckle (think about it) ideas:-)
package krc.utilz.io;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.io.File;
import java.io.Reader;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.FileNotFoundException;
* @class: krc.utilz.io.Filez
* A collection of static "file handling" helper methods.
public abstract class Filez
public static final int BFRSIZE = 4096;
* reads the given file into one big string
* @param String filename - the name of the file to read
* @return the contents filename
public static String read(String filename)
throws FileNotFoundException
return Filez.read(new FileReader(filename));
* Reads the contents of the given reader into one big string, and closes
* the reader.
* @param java.io.Reader reader - a subclass of Reader to read from.
* @return the whole contents of the given reader.
public static String read(Reader in)
try {
StringBuffer out = new StringBuffer();
try {
char[] bfr = new char[BFRSIZE];
int n = 0;
while( (n=in.read(bfr,0,BFRSIZE)) > 0 ) {
out.append(bfr,0,n);
} finally {
if(in!=null)in.close();
return out.toString();
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* (re)writes the given content to the given filename
* @param String content - the new contents of the fil
* @param String filename - the name of the file to write.
public static void write(String content, String filename) {
try {
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(filename));
out.write(content);
} finally {
if(out!=null)out.close();
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* Appends the given content to the given filename.
* @param String content - the string to write to the file.
* @param String filename - the name of the file to write to.
public static void append(String content, String filename) {
try {
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(filename, true)); //true=append
out.write(content);
} finally {
if(out!=null)out.close();
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* reads each line of the given file into an array of strings.
* @param String filename - the name of the file to read
* @return a fixed length array of strings containing file contents.
public static String[] readArray(String filename)
throws FileNotFoundException
return readList(filename).toArray(new String[0]);
* reads each line of the given file into an ArrayList of strings.
* @param String filename - the name of the file to read
* @return an ArrayList of strings containing file contents.
public static ArrayList<String> readArrayList(String filename)
throws FileNotFoundException
return (ArrayList<String>)readList(filename);
* reads each line of the given file into a List of strings.
* @param String filename - the name of the file to read
* @return an List handle ArrayList of strings containing file contents.
public static List<String> readList(String filename)
throws FileNotFoundException
try {
BufferedReader in = null;
List<String> out = new ArrayList<String>();
try {
in = new BufferedReader(new FileReader(filename));
String line = null;
while ( (line = in.readLine()) != null ) {
out.add(line);
} finally {
if(in!=null)in.close();
return out;
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* reads the whole of the given file into an array of bytes.
* @param String filename - the name of the file to read
* @return an array of bytes containing the file contents.
public static byte[] readBytes(String filename)
throws FileNotFoundException
return( readBytes(new File(filename)) );
* reads the whole of the given file into an array of bytes.
* @param File file - the file to read
* @return an array of bytes containing the file contents.
public static byte[] readBytes(File file)
throws FileNotFoundException
try {
byte[] out = null;
InputStream in = null;
try {
in = new FileInputStream(file);
out = new byte[(int)file.length()];
int size = in.read(out);
} finally {
if(in!=null)in.close();
return out;
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* do files A & B have the same contents
* @param String filenameA - the first file to compare
* @param String filenameA - the second file to compare
* @return boolean do-these-two-files-have-the-same-contents?
public static boolean isSame(String filenameA, String filenameB)
throws FileNotFoundException
try {
File fileA = new File(filenameA);
File fileB = new File(filenameB);
//check for same physical file
if( fileA.equals(fileB) ) return(true);
//compare sizes
if( fileA.length() != fileB.length() ) return(false);
//compare contents (buffer by buffer)
boolean same=true;
InputStream inA = null;
InputStream inB = null;
try {
inA = new FileInputStream(fileA);
inB = new FileInputStream(fileB);
byte[] bfrA = new byte[BFRSIZE];
byte[] bfrB = new byte[BFRSIZE];
int sizeA=0, sizeB=0;
do {
sizeA = inA.read(bfrA);
sizeB = inA.read(bfrB);
if ( sizeA != sizeB ) {
same = false;
} else if ( sizeA == 0 ) {
//do nothing
} else if ( !Arrays.equals(bfrA,bfrB) ) {
same = false;
} while (same && sizeA != -1);
} finally {
Clozer.close(inA, inB);
return(same);
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* checks the given filename exists and is readable
* @param String filename = the name of the file to "open".
* @param OPTIONAl String type = a short name for the file used to identify
* the file in any exception messages.
* For example: "input", "input data", "DTD", "XML", or whatever.
* @return a File object for the given filename.
* @throw FileNotFoundException if the given file does not exist.
* @throw IOException if the given file is unreadable (usually permits).
public static File open(String filename)
throws FileNotFoundException
return(open(filename,"input"));
public static File open(String filename, String type)
throws FileNotFoundException
try {
File file = new File(filename);
String fullname = file.getCanonicalPath();
if(!file.exists()) throw new FileNotFoundException(type+" file does not exist: "+fullname);
if(!file.canRead()) throw new RuntimeIOException(type+" file is not readable: "+fullname);
return(file);
} catch (IOException e) {
throw new RuntimeIOException(e.getMessage(), e);
* gets the filename-only portion of a canonical-filename, with or without
* the extension.
* @param String path - the full name of the file.
* OPTIONAL @param boolean cutExtension - if true then remove any .ext
* @return String the filename-only (with or without extension)
public static String basename(String path) {
return(basename(path,false));
public static String basename(String path, boolean cutExtension)
String fname = (new File(path)).getName();
if (cutExtension) {
int i = fname.lastIndexOf(".");
if(i>0) fname = fname.substring(0,i);
return(fname);
}Use it freely. Modify it. Improve it, and pass it back to the community free of charge, except if you are a serving member of the military (any of them), a spook, a drug dealer, an arms manufacturer, an arms dealer, a defense contractor, or a "security consulant", in which case you can go fuck yourself, sorry.
Cheers. Keith. -
I need help with copying files in java?
hi, i use the following code sample to copy a directory structure and its files.
It copy's the directory-structure, but all the files in it have 0kb as size. except one file.
Here's the code:
public static void copyDir(String source, String target)
String [] listing = new String [0];
FileReader in = null;
FileWriter out = null;
String sourcePath = source;
String targetPath = target;
// Maakt directory onder target directory
File f = new File(targetPath);
f.mkdir();
// Maakt filelist van bestanden in source-directory
f = new File(sourcePath);
listing = f.list();
for(int i = 0; i < listing.length; i++)
f = new File(sourcePath + listing);
if(f.isDirectory())
copyDir(source + listing[i] + File.separatorChar,
target + listing[i] + File.separatorChar);
else
try
in = new FileReader(sourcePath + listing[i]);
out = new FileWriter(targetPath + listing[i]);
int t;
while (-1 != (t = in.read()))
out.write(t);
try { Thread.sleep(200); } catch (InterruptedException e) { }
System.out.println("Copied: " + sourcePath + listing[i]);
catch (Exception e)
System.out.println(e);Here is a quick copy program that works. You'll need to deal with the exception instead of just throwing it though.
import java.io.*;
public class Copy
private static void copy(String source, String target) throws IOException
// Create directory
File file=new File(target);
file.mkdirs();
// Get contents
file=new File(source);
File[] files=file.listFiles();
// Copy files
int length;
byte[] buffer=new byte[1024];
for(int i=0; i<files.length; i++)
String destination=target+File.separator+files[ i ].getName();
if(files[ i ].isDirectory())
copy(files[ i ].getPath(), destination);
else
FileInputStream in=new FileInputStream(files[ i ]);
FileOutputStream out=new FileOutputStream(destination);
while((length=in.read(buffer))!=-1)
out.write(buffer, 0, length);
in.close();
out.close();
public static void main(String[] args) throws IOException
copy(args[0], args[1]);
}[\code] -
IMPORTANT. copying files in java
i would like to know how do i copy a file form one dir to another or do i have to just read from one file and write it to the other?? thanks for all the help
look at the "java.nio.*" package:
http://java.sun.com/j2se/1.4/docs/api/java/nio/channels/package-summary.html
http://java.sun.com/j2se/1.4/docs/api/java/nio/package-summary.html -
Best way to find and copy files
If i have a list of 2000 file names and want to find:
if they exist in folder x
then copy to folder y
else
output an error messege to txt file.
What would the most efficient way to do this be? So far i've used listFiles() and put a >HUGE< directory listing into an Array. Then I did a comparison for each file name in the list against the array. I know this cant be the most efficient way. I posted earlier in the board but for some reason NO one answered. Can anyone suggest and easier way to do this? and what is the best way to copy files in java? opening a bufferwriter etc? Essectially, im doing a restore from multiple backup directories to the original directory. Please help me if you can take the time.
Thank you,
jonIf i have a list of 2000 file names and want to
find:
if they exist in folder x
then copy to folder y
else
output an error messege to txt file.
What would the most efficient way to do this be?In a loop just read and write each file. If it does not exist, print an error.
So far i've used listFiles() and put a >HUGE< directory listing into an Array. A directory with a million entries is a HUGE directory, I guess you only have a few thousand.
I wouldn't bother reading the files into memory, you only need 2000 of them.
Then I did a comparison for each file name in the list against the array. The OS will do this for you when you try to open the file, which you will have to do anyway to copy it.
I know this cant be the most efficient way. More efficient way, don't do it at all.
I posted earlier in the board but for some reason NO one answered. Perhaps the problem seemed too obvious.
Can anyone suggest and easier way to do this?
and what is the best way to copy files in java? Copy one at a time.
opening a bufferwriter etc? Read a block of say 64K at a time. No buffers required.
Essectially, im
doing a restore from multiple backup directories to
the original directory. Please help me if you can
take the time.If you are recovering from a backup, the most important thing is ensuring the data is correct and valid, speed is less important. (It is no good if it is fast but corrupt)
Coping 2000 files is going to be only as fast as your drive(s) can handle. How you copy the file is less important. -
How to copy a file from Java code
I have written a file through Java code in folder, say, "A". Now, I want a copy of that file exactly the same in some other folder "B". How, it can be done?
http://java.sun.com/docs/books/tutorial/essential/io/streams.html
-
Hi,
My code is something like this..
Which is trying to copy or move a file from one location to other.
Problem is I do not see the last modified date getting preserved,
in the copied file.
Why does this happen ? and how to preserve the last modified date
to copied file ?
File fTempRead = new File(fFrom.getAbsolutePath(), filename);
File fTempWrite = new File(fTo.getAbsolutePath(), filename);
if (fTempRead.canRead()) {
lastmodified = fTempRead.lastModified();
fTempWrite.setLastModified(lastmodified);
RandomAccessFile randomWrite = new RandomAccessFile(fTempWrite, Messages.getString("FileIOHandler.14")); //$NON-NLS-1$
FileChannel fWriteChannel = randomWrite.getChannel();
RandomAccessFile randomRead = new RandomAccessFile(fTempRead, Messages.getString("FileIOHandler.15")); //$NON-NLS-1$
FileChannel fReadChannel = randomRead.getChannel();
FileLock readLock = fReadChannel.lock(0,fTempRead.length(), false);
FileLock writeLock = fWriteChannel.lock(0, fTempWrite.length(), false);
long fLength = 0l;
byte by[] = new byte[1024];
int byteread = 0;
while ((byteread = randomRead.read(by)) != -1) {
randomWrite.write(by, 0, byteread);
readLock.release();
writeLock.release();
randomRead.close();
randomWrite.close();
if(move) {
boolean r = fTempRead.delete();
if(!r) {
throw new FileMoveException(sb.toString());
}I'm not sure, but I would imagine that if you first setLastModified, and then write the file, the lastModified will be set again by the write.
Try calling setLastModified after you're done writing. (Not sure if you need to do it before or after close(). Try it each way.) -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
CPU Jul-09 Installation - Error Cannot copy file from 'libjox10.so' to
Hi All, I received this error while I was installing the last CPU on a 10.2.0.4 Oracle Instance running on a HP-UX Itanium System:
Patch 8568398:
Copy Action: Desctination File "/u02/app/oracle/product/10.2/Db_1/lib/libjox10.so" is not writeable.
'oracle.rdbms, 10.2.0.4.0': Cannot copy file from 'libjox10.so' to '/u02/app/oracle/product/10.2/Db_1/lib/libjox10.so'
I checked metalink' site with no similar results found.
Could anybody help me?
Should I run /usr/sbin/slibclean and remove the last patch (Patch 8568398) and then try again?
This is the complete log...
$ opatch version
Invoking OPatch 10.2.0.4.7
OPatch Version: 10.2.0.4.7
OPatch succeeded.
$ sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Jul 17 16:29:29 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
$ lsnrctl stop
LSNRCTL for HPUX: Version 10.2.0.4.0 - Production on 17-JUL-2009 16:32:29
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Hostname)(PORT=1521)))
The command completed successfully
$ emctl stop dbconsole
Oracle Enterprise Manager 10g Database Control Release 10.2.0.4.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.
http://hostname:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 10g Database Control ...
... Stopped.
$unzip p8534387_10204_HPUX-IA64.zip
<...>
$ cd 8534387
$ opatch napply -skip_subset -skip_duplicate
Invoking OPatch 10.2.0.4.7
Oracle Interim Patch Installer version 10.2.0.4.7
Copyright (c) 2009, Oracle Corporation. All rights reserved.
UTIL session
Oracle Home : /u02/app/oracle/product/10.2/Db_1
Central Inventory : /u02/app/oracle/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 10.2.0.4.7
OUI version : 10.2.0.4.0
OUI location : /u02/app/oracle/product/10.2/Db_1/oui
Log file location : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch2 009-07-17_16-38-05PM.log
Patch history file: /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch_ history.txt
Invoking utility "napply"
Checking conflict among patches...
Checking if Oracle Home has components required by patches...
Checking skip_duplicate
Checking skip_subset
Checking conflicts against Oracle Home...
OPatch continues with these patches: 7155248 7155249 7155250 7155251 7155252 7155253 7155254 7197583 7375611 7375613 7375617 7609057 7609058 8309587 8309592 8309623 8309632 8309637 8309642 8534387 8568395 8568397 8568398 8568402 8568404 8568405
Do you want to proceed? y
y
User Responded with: Y
Running prerequisite checks...
Prerequisite check "CheckApplicable" failed.
The details are:
Patch 8568398:
Copy Action: Desctination File "/u02/app/oracle/product/10.2/Db_1/lib/libjox10.so" is not writeable.
'oracle.rdbms, 10.2.0.4.0': Cannot copy file from 'libjox10.so' to '/u02/app/oracle/product/10.2/Db_1/lib/libjox10.so'
UtilSession failed: Prerequisite check "CheckApplicable" failed.
$ opatch lsinventory -detail
Invoking OPatch 10.2.0.4.7
Oracle Interim Patch Installer version 10.2.0.4.7
Copyright (c) 2009, Oracle Corporation. All rights reserved.
Oracle Home : /u02/app/oracle/product/10.2/Db_1
Central Inventory : /u02/app/oracle/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 10.2.0.4.7
OUI version : 10.2.0.4.0
OUI location : /u02/app/oracle/product/10.2/Db_1/oui
Log file location : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch2009-07-17_17-53-30PM.log
Patch history file: /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch_history.txt
Lsinventory Output file location : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/lsinv/lsinventory2009-07-17_17-53-30PM.txt
Installed Top-level Products (2):
Oracle Database 10g 10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 3 10.2.0.4.0
There are 2 products installed in this Oracle Home.
Installed Products (190):
Agent Required Support Files 10.2.0.1.0
Agent Required Support Files Patch 10.2.0.4.0
Assistant Common Files 10.2.0.1.0
Assistant Common Files Patch 10.2.0.4.0
Bali Share 1.1.18.0.0
Buildtools Common Files 10.2.0.1.0
Character Set Migration Utility 10.2.0.1.0
Character Set Migration Utility Patch 10.2.0.4.0
Database Configuration and Upgrade Assistants 10.2.0.1.0
Database Configuration and Upgrade Assistants Patch 10.2.0.4.0
Database SQL Scripts 10.2.0.1.0
Database SQL Scripts Patch 10.2.0.4.0
Database Workspace Manager 10.2.0.1.0
Database Workspace Manager 10.2.0.4.0
DBJAVA Required Support Files 10.2.0.1.0
DBJAVA Required Support Files Patch 10.2.0.4.0
Enterprise Edition Options 10.2.0.1.0
Enterprise Manager Agent Core 10.2.0.1.0
Enterprise Manager Agent Core Patch 10.2.0.4.0a
Enterprise Manager Agent DB 10.2.0.1.0
Enterprise Manager Agent DB 10.2.0.4.0
Enterprise Manager Baseline 10.2.0.1.0
Enterprise Manager Baseline 10.2.0.4.0
Enterprise Manager Common Core Patch 10.2.0.4.0a
Enterprise Manager Common Files 10.2.0.1.0
Enterprise Manager Minimal Integration 10.2.0.1.0
Enterprise Manager plugin Common Files 10.2.0.1.0
Enterprise Manager plugin Common Files 10.2.0.1.0
Enterprise Manager plugin Common Files Patch 10.2.0.4.0
Enterprise Manager Repository Core 10.2.0.1.0
Enterprise Manager Repository Core patch 10.2.0.4.0a
Enterprise Manager Repository DB 10.2.0.1.0
Enterprise Manager Repository DB 10.2.0.4.0
Generic Connectivity Common Files 10.2.0.1.0
Generic Connectivity Common Files Patch 10.2.0.4.0
HAS Common Files 10.2.0.1.0
HAS Common Files Patch 10.2.0.4.0
HAS Files for DB 10.2.0.1.0
HAS Files for DB Patch 10.2.0.4.0
Installation Common Files 10.2.0.1.0
Installation Common Files Patch 10.2.0.4.0
Installer SDK Component 10.2.0.4.0
iSQL*Plus 10.2.0.1.0
iSQL*Plus 10.2.0.4.0
Java Runtime Environment 1.4.2.14.0
JDBC Common Files 10.2.0.1.0
JDBC Common Files 10.2.0.4.0
LDAP Required Support Files 10.2.0.1.0
LDAP Required Support Files Patch 10.2.0.4.0
OLAP SQL Scripts 10.2.0.1.0
OLAP SQL Scripts Patch 10.2.0.4.0
Oracle Advanced Security 10.2.0.1.0
Oracle Advanced Security Patch 10.2.0.4.0
Oracle Call Interface (OCI) 10.2.0.1.0
Oracle Call Interface (OCI) Patch 10.2.0.4.0
Oracle Clusterware RDBMS Files 10.2.0.1.0
Oracle Clusterware RDBMS Files Patch 10.2.0.4.0
Oracle Code Editor 1.2.1.0.0I
Oracle Configuration Manager 10.2.7.1.0
Oracle Containers for Java 10.2.0.1.0
Oracle Containers for Java 10.2.0.4.0
Oracle Core Required Support Files 10.2.0.1.0
Oracle Core Required Support Files Patch 10.2.0.4.0
Oracle Data Mining RDBMS Files 10.2.0.1.0
Oracle Data Mining RDBMS Files Patch 10.2.0.4.0
Oracle Database 10g 10.2.0.1.0
Oracle Database 10g 10.2.0.1.0
Oracle Database 10G 32 bit 10.1.0.2.0
Oracle Database 10g interMedia Files 10.2.0.1.0
Oracle Database 10g interMedia Files Patch 10.2.0.4.0
Oracle Database 10g Patch 10.2.0.4.0
Oracle Database 10g Patch 10.2.0.4.0
Oracle Database 10g Release 2 Patch Set 3 10.2.0.4.0
Oracle Database User Interface 2.2.13.0.0
Oracle Database Utilities 10.2.0.1.0
Oracle Database Utilities Patch 10.2.0.4.0
Oracle Display Fonts 9.0.2.0.0
Oracle Enterprise Manager Console DB 10.2.0.1.0
Oracle Enterprise Manager Console DB 10.2.0.4.0
Oracle Extended Windowing Toolkit 3.4.38.0.0
Oracle Globalization Support 10.2.0.1.0
Oracle Globalization Support Patch 10.2.0.4.0
Oracle Help For Java 4.2.6.1.0
Oracle Help for the Web 1.1.10.0.0
Oracle Ice Browser 5.2.3.6.0
Oracle interMedia 10.2.0.1.0
Oracle interMedia Annotator 10.2.0.1.0
Oracle interMedia Client Option 10.2.0.1.0
Oracle interMedia Client Option Patch 10.2.0.4.0
Oracle interMedia Java Advanced Imaging 10.2.0.1.0
Oracle interMedia Java Advanced Imaging Patch 10.2.0.4.0
Oracle interMedia Locator 10.2.0.1.0
Oracle interMedia Locator Patch 10.2.0.4.0
Oracle interMedia Locator RDBMS Files 10.2.0.1.0
Oracle interMedia Locator RDBMS Files Patch 10.2.0.4.0
Oracle interMedia Patch 10.2.0.4.0
Oracle Internet Directory Client 10.2.0.1.0
Oracle Internet Directory Client Patch 10.2.0.4.0
Oracle Java Client 10.2.0.1.0
Oracle Java Client Patch 10.2.0.4.0
Oracle JDBC Thin Driver for JDK 1.2 10.2.0.1.0
Oracle JDBC Thin Driver for JDK 1.2 Patch 10.2.0.4.0
Oracle JDBC Thin Driver for JDK 1.4 10.2.0.1.0
Oracle JDBC Thin Driver for JDK 1.4 Patch 10.2.0.4.0
Oracle JDBC/OCI Instant Client 10.2.0.1.0
Oracle JDBC/OCI Instant Client Patch 10.2.0.4.0
Oracle JFC Extended Windowing Toolkit 4.2.33.0.0
Oracle JVM 10.2.0.1.0
Oracle JVM Patch 10.2.0.4.0
Oracle LDAP administration 10.2.0.1.0
Oracle LDAP administration patch 10.2.0.4.0
Oracle Locale Builder 10.2.0.1.0
Oracle Message Gateway Common Files 10.2.0.1.0
Oracle Message Gateway Common Files Patch 10.2.0.4.0
Oracle Net 10.2.0.1.0
Oracle Net Listener 10.2.0.1.0
Oracle Net Listener Patch 10.2.0.4.0
Oracle Net Patch 10.2.0.4.0
Oracle Net Required Support Files 10.2.0.1.0
Oracle Net Required Support Files Patch 10.2.0.4.0
Oracle Net Services 10.2.0.1.0
Oracle Notification Service 9.0.4.0.0
Oracle Notification Service Patch 10.2.0.4.0
Oracle OLAP 10.2.0.1.0
Oracle OLAP API 10.2.0.1.0
Oracle OLAP API Patch 10.2.0.4.0
Oracle OLAP Patch 10.2.0.4.0
Oracle OLAP RDBMS Files 10.2.0.1.0
Oracle OLAP RDBMS Files Patch 10.2.0.4.0
Oracle One-Off Patch Installer 10.2.0.4.0
Oracle Partitioning 10.2.0.1.0
Oracle Partitioning Patch 10.2.0.4.0
Oracle Programmer 10.2.0.1.0
Oracle RAC Required Support Files-HAS 10.2.0.1.0
Oracle RAC Required Support Files-HAS Patch 10.2.0.4.0
Oracle Real Application Testing 10.2.0.4.0
Oracle Recovery Manager 10.2.0.1.0
Oracle Recovery Manager Patch 10.2.0.4.0
Oracle Required Support Files 32 bit 10.2.0.0.0
Oracle Required Support Files 32 bit Patch 10.2.0.4.0
Oracle Spatial 10.2.0.1.0
Oracle Starter Database 10.2.0.1.0
Oracle Starter Database Patch 10.2.0.4.0
Oracle Text 10.2.0.1.0
Oracle Text Patch 10.2.0.4.0
Oracle UIX 2.1.22.0.0
Oracle Universal Installer 10.2.0.4.0
Oracle Wallet Manager 10.2.0.1.0
Oracle Wallet Manager Patch 10.2.0.4.0
Oracle XML Development Kit 10.2.0.1.0
Oracle XML Development Kit Patch 10.2.0.4.0
Parser Generator Required Support Files 10.2.0.1.0
Perl Interpreter 5.8.3.0.1
Perl Interpreter Patch 5.8.3.0.1a
PL/SQL 10.2.0.1.0
PL/SQL 10.2.0.4.0
PL/SQL Embedded Gateway 10.2.0.1.0
PL/SQL Embedded Gateway Patch 10.2.0.4.0
Platform Required Support Files 10.2.0.1.0
Platform Required Support Files 10.2.0.4.0
Precompiler Common Files 10.2.0.1.0
Precompiler Common Files Patch 10.2.0.4.0
Precompiler Required Support Files 10.2.0.1.0
Precompiler Required Support Files Patch 10.2.0.4.0
RDBMS Required Support Files 10.2.0.1.0
RDBMS Required Support Files for Instant Client 10.2.0.1.0
RDBMS Required Support Files for Instant Client Patch 10.2.0.4.0
RDBMS Required Support Files Patch 10.2.0.4.0
regexp 2.1.9.0.0
Required Support Files 10.2.0.1.0
Sample Schema Data 10.2.0.1.0
Sample Schema Data Patch 10.2.0.4.0
Secure Socket Layer 10.2.0.1.0
Secure Socket Layer Patch 10.2.0.4.0
SQL*Plus 10.2.0.1.0
SQL*Plus 10.2.0.4.0
SQL*Plus Required Support Files 10.2.0.1.0
SQL*Plus Required Support Files Patch 10.2.0.4.0
SQLJ Runtime 10.2.0.1.0
SQLJ Runtime Patch 10.2.0.4.0
SSL Required Support Files for InstantClient 10.2.0.1.0
SSL Required Support Files for InstantClient Patch 10.2.0.4.0
Sun JDK 1.4.2.17.0
Sun JDK extensions 9.2.0.1.0
XDK Required Support Files 10.2.0.1.0
XDK Required Support Files Patch 10.2.0.4.0
XML Parser for Java 10.2.0.1.0
XML Parser for Java Patch 10.2.0.4.0
XML Parser for Oracle JVM 10.2.0.1.0
XML Parser for Oracle JVM Patch 10.2.0.4.0
There are 190 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
OPatch succeeded.
$
$ more /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch_history.txt
Date & Time : Fri Jul 17 16:02:17 GMT-03:00 2009
Oracle Home : /u02/app/oracle/product/10.2/Db_1
OPatch Ver. : 10.2.0.4.7
Current Dir : /u02/app/oracle/product/10.2/Db_1
Command : -v
Log File : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch2009-07-17_16-02-17PM.log
Date & Time : Fri Jul 17 16:38:05 GMT-03:00 2009
Oracle Home : /u02/app/oracle/product/10.2/Db_1
OPatch Ver. : 10.2.0.4.7
Current Dir : /home/ora10g/8534387
Command : napply -skip_subset -skip_duplicate
Log File : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch2009-07-17_16-38-05PM.log
Date & Time : Fri Jul 17 17:53:30 GMT-03:00 2009
Oracle Home : /u02/app/oracle/product/10.2/Db_1
OPatch Ver. : 10.2.0.4.7
Current Dir : /home/ora10g/8534387
Command : lsinventory -detail
Log File : /u02/app/oracle/product/10.2/Db_1/cfgtoollogs/opatch/opatch2009-07-17_17-53-30PM.log
$
Please let me know if you need more info.
Regards, and thanks in advance!
MartinYou were right. It was a permissions issue:
hostname:/root# ls -ltr /u02/app/oracle/product/10.2/Db_1/lib/libjox10.so
-r-xr-xr-x 1 ora10g oinstall 20041728 Apr 23 2008 /u02/app/oracle/product/10.2/Db_1/lib/libjox10.so
Thanks.
damorgan wrote:
"is not writeable." means one of two things.
1. It does not exist.
2. Permissions are not set correctly.
Determining which it is ... that is the first step. -
How to copy file from one location to another
Hi,
I am new to java, I tried the following code to move the file from one location to another
public class CopyFiles {
public String copy ( File source, File target)
throws IOException {
FileChannel sourceChannel = null;
FileChannel targetChannel =null;
try {
sourceChannel =new FileInputStream(source).getChannel();
targetChannel= new FileOutputStream(target).getChannel();
targetChannel.transferFrom(sourceChannel, 0,
sourceChannel.size());
finally {
targetChannel.close();
sourceChannel.close();
return "Success";
public static void main(String [] args) throws Exception{
File source = new File("C:\\users\\download.pdf");
File destinationFile = new File("C:\\apple\\download.pdf");
copy(source, destinationFile);
The above code is working perfectly, but I Don't want to include the file name in destination file. i.e. File destinationFile=new File("C:\\apple"), and at the same time the pdf with same name has to get stored in the destination location, how can I achieve this.kameshb wrote:
I Don't want to include the file name in destination file. i.e. File destinationFile=new File("C:\\apple"), and at the same time the pdf with same name has to get stored in the destination location, how can I achieve this.It's not totally clear what you're saying here, but what I think you mean is that you don't want to explicitly set the destination file name--you want to just give the copy the same name as the original. Yes?
If that's the case, then break the original up into separate directory and file name portions, and then construct the destination path from the destination directory plus original file name. You can do that by manipulating the full path string, or by using the methods in java.io.File. -
Copy file from a location to another
I work on a Java process that must be optimized and I have some questions.
This process includes a part of copying a file from a location from another (to be more specific, all files that exist in a directory, to copy in another directory), wich technique is more efficient and quickly? To copy using FileInputStream/FileOutputStream in Java or using a java Runtime process that calls a copy command of the Operating System?I work on a Java process that must be optimized and I
have some questions.
This process includes a part of copying a file from a
location from another (to be more specific, all files
that exist in a directory, to copy in another
directory), wich technique is more efficient and
quickly? To copy using
FileInputStream/FileOutputStream in Java or using a
java Runtime process that calls a copy command of the
Operating System?Neither. Use the FileChannels in the nio package if you can:
/* Note: Proper resource closing and exception handling is not done here */
try {
// Create channel on the source
FileChannel srcChannel = new
FileInputStream("srcFilename").getChannel();
// Create channel on the destination
FileChannel dstChannel = new
FileOutputStream("dstFilename").getChannel();
// Copy file contents from source to destination
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
// Close the channels
srcChannel.close();
dstChannel.close();
} catch (IOException e) {
}Spawning a Runtime process is probably the least efficient way to do it.
- N -
How can i use JWSDP1.6 from Ant tool to convert .wsdl file into Java class
Hi All,
i m very new in the development field.plese help me...
i have a .wsdl file and i have to make some modification in the file and return this file with build file used in Ant tool.
means my requirement is to conver the .wsdl file into java class,modify it and convert back to wsdl file.how can i do it using JWSDP1.6 and Ant tool.
thanks in advance...
Vikram Singhlemilanais wrote:
hello!
I have developpe an animation with flash. before give it to othe person in order to use it, i would like to secure it by integrated a security module inside the software.Secure it from what? Being played? Copied? Deleted? Modified?
Because, i am a java developper, i have choose Netbeans 6.1 to secure it.That has to be the most random thing I've read in some time.
do you know how can i do to integrate my animation .swf inside my java class?Java can't play SWF files and Flash can't handle Java classes, so what you're suggesting here doesn't make a lot of sense. -
How do I Copy files from one directory to another?
I know how to move files using the renameTo() method of File class, but is there a simple way to copy files, without the need of reading the input stream form one file and writing to a new one?
Hi all,
I ripped this off the jakarta-ant project's file copier (with a small tweak)..
package com.museumcompany.util;
import java.io.IOException;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.reflect.Method;
import java.text.DecimalFormat;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
* This class also encapsulates methods which allow Files to be
* refered to using abstract path names which are translated to native
* system file paths at runtime as well as copying files or setting
* there last modification time.
* @author [email protected]
* @author Conor MacNeill
* @author Stefan Bodewig
* @version $Revision: 1.8 $
public class FileUtils {
private static Random rand = new Random(System.currentTimeMillis());
private static Object lockReflection = new Object();
* Factory method.
public static FileUtils newFileUtils() {
return new FileUtils();
* Empty constructor.
protected FileUtils() {}
* Convienence method to copy a file from a source to a destination.
* Overwrite is prevented, and the last modified is kept.
* @throws IOException
public void copyFile(String sourceFile, String destFile) throws IOException {
copyFile(new File(sourceFile), new File(destFile), false, true);
* Method to copy a file from a source to a
* destination specifying if
* source files may overwrite newer destination files and the
* last modified time of <code>destFile</code> file should be made equal
* to the last modified time of <code>sourceFile</code>.
* @throws IOException
public void copyFile(File sourceFile, File destFile,
boolean overwrite, boolean preserveLastModified)
throws IOException {
if (overwrite || !destFile.exists() ||
destFile.lastModified() < sourceFile.lastModified()) {
if (destFile.exists() && destFile.isFile()) {
destFile.delete();
// ensure that parent dir of dest file exists!
// not using getParentFile method to stay 1.1 compat
File parent = new File(destFile.getParent());
if (!parent.exists()) {
parent.mkdirs();
FileInputStream in = new FileInputStream(sourceFile);
FileOutputStream out = new FileOutputStream(destFile);
byte[] buffer = new byte[8 * 1024];
int count = 0;
do {
out.write(buffer, 0, count);
count = in.read(buffer, 0, buffer.length);
} while (count != -1);
in.close();
out.close();
if (preserveLastModified) {
destFile.setLastModified(sourceFile.lastModified());
public File createTempFile(String prefix, String suffix, File parentDir) {
File result = null;
DecimalFormat fmt = new DecimalFormat("#####");
synchronized (rand) {
do {
result = new File(parentDir,
prefix + fmt.format(rand.nextInt())
+ suffix);
} while (result.exists());
return result; -
Access denied error -- while copying file to a specific directory
Hi Friends,
I have gone through scores of examples and i am failing to understand the right thing to be done to copy a file from one directory to another. Here is my class
package ZipTest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class TestCopy {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
File source = new File("C:\\mkyong\\test_1.txt");
File desc = new File("C:\\GetMe1");
try {
copyFiles(source,desc);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public static void copyFiles(File src, File dest) throws IOException
if (!src.exists())
throw new IOException("copyFiles: Can not find source: " + src.getAbsolutePath()+".");
else if (!src.canRead())
throw new IOException("copyFiles: No right to source: " + src.getAbsolutePath()+".");
if (src.isDirectory())
if (!dest.exists())
if (!dest.mkdirs())
throw new IOException("copyFiles: Could not create direcotry: " + dest.getAbsolutePath() + ".");
String list[] = src.list();
for (int i = 0; i < list.length; i++)
File dest1 = new File(dest, list);
File src1 = new File(src, list[i]);
copyFiles(src1 , dest1);
else
FileInputStream fin = null;
FileOutputStream fout = null;
byte[] buffer = new byte[4096];
int bytesRead;
try
fin = new FileInputStream(src);
fout = new FileOutputStream (dest);
while ((bytesRead = fin.read(buffer)) >= 0)
fout.write(buffer,0,bytesRead);
catch (IOException e)
IOException wrapper = new IOException("copyFiles: Unable to copy file: " +
src.getAbsolutePath() + "to" + dest.getAbsolutePath()+".");
wrapper.initCause(e);
wrapper.setStackTrace(e.getStackTrace());
throw wrapper;
finally
if (fin != null) { fin.close(); }
if (fout != null) { fin.close(); }
But i am getting the following errorjava.io.IOException: copyFiles: Unable to copy file: C:\mkyong\test_1.txttoC:\GetMe1.
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at ZipTest.TestCopy.copyFiles(TestCopy.java:68)
at ZipTest.TestCopy.main(TestCopy.java:18)
Caused by: java.io.FileNotFoundException: C:\GetMe1 (Access is denied)
... 5 more
It would be really helpful to have your guidance.
Thanks & Regards
VSvishnuS1984 wrote:
Hi Friends,
I have gone through scores of examples and i am failing to understand the right thing to be done to copy a file from one directory to another. Here is my class...So let's see... C:\GetMe1 is a directory on your machine, right? And this is what you are doing with that directory:
public static void copyFiles(File src, File dest) throws IOException
// dest is a 'File' object but represents the C:\GetMe1 directory, right?
fout = new FileOutputStream (dest);If it's a directory, where in your code are you appending the source file name to the path, before trying to open an output stream on it? You're not.
BTW, this is awful:
catch (IOException e)
IOException wrapper = new IOException("copyFiles: Unable to copy file: " +
src.getAbsolutePath() + "to" + dest.getAbsolutePath()+".");
wrapper.initCause(e);
wrapper.setStackTrace(e.getStackTrace());
throw wrapper;
}1) You're hiding the original IOException and replacing it with your own? For what good purpose?
2) Even if you had a good reason to do that, this would be simpler and better:
throw new IOException("your custom message goes here", e);
rather than explicitly invokign initCause and setStackTrace. Yuck! -
HOw to create a Batch file for java application and whats the use of this ?
HI,
How to create a Batch file for java application ?
And whats the use of creating batch file ?
Thanks in advanceFirst of all, you're OT.
Second, you can find this everywhere in the net.
If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
Otherwise use:
javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
Don't specify the .class extension.
Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
Finally add dukes and give 'hem away.
Bye.
Maybe you are looking for
-
Data Federator not fetching data USING Netweaver BI Connector
Hi Gurus, We have upgraded the BW system to use the Data federator. callback ID that SAP NetWeaver BI uses to contact Data Federator has been configured as mentioned in guide. we have already configured the CONNECTOR and we are able to test the conne
-
Hi All, I have developed a program to display two alv reports. The program when executed displays the first report and on the click of a push button it wud display the second report. The standard icons are all working in the first report but few icon
-
How many iPODS can you download your music library to?
I've purchased 3 iPODS over time and have downloaded from my iMAC to each. Is there a limit to how many iPODS I can download to? On the last one I got a message saying I only had one more left. These are all legal purchases. Why is there a limit?
-
Hi, How can I produce my own icons to appear next to nodes in a JTree. At the moment I am using gifs I got elsewhere, but I want to design my own for custom display. Thanks for any help, Claire
-
Scheduling the IDOCs- PFAL to PI
Hi All, Can you help me on regarding this : We have scenario where ECC(HCM) sending the master and reference data of PersonnelAdministration(PA)/Organization Management(OM) to MDM and our design confirmed that usign PFAL transaction for send the m