Skip to main content

How to get a clob file from data base and pass one instance of that file to another java method....

1 reply [Last post]
hipintu
Offline
Joined: 2011-02-09
Points: 0

Here is my sample code.

public File getFile(----)
{
File file=null;

try {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, pass);
System.out.println("Connected to EBS");
//String sql = "SELECT * FROM ebswo where woid='"+origURL+"'";
String sql = "SELECT * FROM ebswo where woid='wso002'";
Statement stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery(sql);
System.out.println();
while (rs.next()) {
docName = rs.getString(2);
System.out.println("Document Name in buildDocInfo>>>>>" + docName);

file = new File(docName);
Reader reader = rs.getCharacterStream(3);
FileWriter writer = new FileWriter(file);
char[] buffer = new char[1];
while (reader.read(buffer) > 0) {
writer.write(buffer);
}
System.out.println("File Created in buildDocInfo>>>>");
writer.close();
}
conn.close();

}
return file;
}

So my requirement is how can I get one instance of the file without storing the file in the local hard disk.

i.e I have to pass the file file instance dynamically with out storing the parent file into local drive.

please reply me soon..

Thanks In advance

Srinibash

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tianwang
Offline
Joined: 2008-06-07
Points: 0

Most of the time, the thing you are passing your File instance into can accept byte[] or InputStream. If os, you do not need to create the file in your local disk. If it insists on an instance of type File, you are out of luck there.