If you're using Oracle, use the sql loader.
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of guo_yonglin
Sent: Friday, November 17, 2000 11:30 AM
To: [EMAIL PROTECTED]
Subject: Re: convert text format to DB ??
you can read file line by line. for each line, split it and put in a string
array, then insert into database.
Here is a source code example,
hope this helps!
Yonglin
***********************************
import java.io.*;
import java.util.*;
class FileReadTest {
public static void main (String[] argv) {
if (argv.length == 0 ||argv[0].equals("-help"))
{
System.out.println("Usage: java textfilename");
System.exit(1);
}
FileReadTest t = new FileReadTest();
t.readMyFile(argv[0]);
}
//--------------------------------------------< readMyFile >--------//
void readMyFile(String filename) {
String record = null;
int recCount = 0;
try {
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
recCount++;
System.out.println(recCount + ": " + record);
FileReadTest tt = new FileReadTest();
String[] temp = tt.split(record,"|");
System.out.println("temp.length()"+temp.length);
for (int i =0;i<temp.length; i++)
{
System.out.println(temp[i]+" ");
}
}
} catch (IOException e) {
// catch possible io errors from readLine()
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
} // end of readMyFile()
private String[] split(String str, String delim)
{
Vector v = new Vector();
StringTokenizer tokenizer = new StringTokenizer(str, delim);
while (tokenizer.hasMoreTokens())
{
v.addElement(tokenizer.nextToken());
}
String[] ret = new String[v.size()];
for (int i = 0; i < ret.length; i++)
{
ret[i] = (String) v.elementAt(i);
}
return ret;
}
} // end of class
***********************************
> -----Original Message-----
> From: sufi malak [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, November 16, 2000 10:06 PM
> To: [EMAIL PROTECTED]
> Subject: convert text format to DB ??
>
>
> Hi, is there any code that convert a text format separated by "-" to a
> database format, for example:
> a text format that has lines like this :
> 123 - first - last - descr
>
> I need a tool ( java or any) to convert them to a database,
> 123 go to SSN column,
> first go to FIRSTNAME column
> last go to LASNAME column
> descr go to DESCRIPTION column
>
> Thanks your help will be appreciated.
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".