Closed Thread Icon

Topic awaiting preservation: Help... plz im having problems regarding File Upload (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25849" title="Pages that link to Topic awaiting preservation: Help... plz im having problems regarding File Upload (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Help... plz im having problems regarding File Upload <span class="small">(Page 1 of 1)</span>\

 
javeo_lineo
Obsessive-Compulsive (I) Inmate

From:
Insane since: May 2005

posted posted 05-24-2005 07:22

I'm facing problem with File Uploading. Im uploading text files.
( Could you please help me.)

- In the source, the part "public class DocData implements Serializable" (the later part of the source), Im having errors in compiling it, specifically in openning the file & converting it to StringBuffer...

- How do I make my file dynamic? Because I just hardcoded the specific file...


Thank you very much....

javeo_lineo

-----------------

//Serializing object..
public class DocData implements Serializable
{
String dataText;
String fName;
String record = null;
int recCount = 0;

void readMyFile()
{

//Read file...
try {

FileReader fr = new FileReader("test.html");
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null)
{
//recCount++;
//System.out.print(recCount + ":" + record);
}

}catch (IOException e)
{
//Catch possible io errors from readLine()
System.out.println("Error reading file IOException error!");
e.printStackTrace();
}

br.close();

}


//Write to buffer...
StringBuffer buf = new StringBuffer();

while ((record = fr.readLine()) != null)
{
buf.append(record);
}

DocData data = new DocData();

data.fName = "test.html";
data.dataText = buf.toString();
}

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 05-24-2005 13:46

what is the compile error you get?

to make it dynamic just put the filename in a string variable.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-24-2005 17:40

There's a lot here that we need some help with.

First how is this object being implemented? Second are you have compile time errors or runtime errors? Having issues with File uploads sounds like a run time error. Third this code seems to be more about file reading than file uploading. Is there more we need?


If this is a web page then you can usually grab file names from the request object.

If it's a standalone app then check out the Java tutorial for Command line arguments



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu