How to load content of my text file into a Vector?
Hi!
Two questions.
Let say I have used BufferedReader(new FileReader(c:/java/MyText.txt)) to read from MyText.txt file. I want to know how to load content of this file (every line describe each photo in my photo-set) into a Vector? And how to associate lines of MyText.txt as an elements of the Vector?
I am trying to do something, but no results.
try{
BufferedReader reader = new BufferedReader(new FileReader("c:/java/Applications/MyText.txt"));
String str=reader.readLine();
JList myList = new JList();
StringTokenizer st = new StringTokenizer(str,"\n");
Vector vr = new Vector(25);
while(st.hasMoreTokens()){
String nextToken = st.nextToken();
vr.addElement(nextToken);
myList.setListData(vr);
TA1.setText(TA1.getText()+
(String)myList.getSelectedValue());
}catch(IOException evt) {};
BufferedReader reader = new BufferedReader(new FileReader("c:/java/Applications/MyText.txt"));
Vector photos = new Vector(0,0);
while(reader.ready())
photos.addElement(reader.readLine());
}good luck,
Felipe
Similar Messages
-
How to load data in plain-text file into database by using EJB?
Hi,
We need to develop an on-line application which requires us to load input data
from a selected plain-text file on the Web server (iplanet server) into the backend
oracle database. How could I use EJB to make it happen? it seems like using Entity
EJB is not feasible.
Really appreciate your help!
CoronaHi Corona,
"Corona Fang" <[email protected]> wrote in message
news:3f3b0ea3$[email protected]..
We need to develop an on-line application which requires us to load inputdata
from a selected plain-text file on the Web server (iplanet server) intothe backend
oracle database. How could I use EJB to make it happen? it seems likeusing Entity
EJB is not feasible.If you are talking about loading thousands of records,
the preferable way is using plain JDBC calls utilizing
batch methods.
Regards,
Slava Imeshev -
How to load the data from excel file into table in oracle using UTL_FI
How to load the data from excel file into table in oracle
and from table to excel file
using UTL_FILE package
Please give me some exampleThis is something i tried in oracle apex
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Regards,
CKLP -
How to convert content of a Text file to String?
Hi,
I need to read the content of a text file and convert it into String and display it on to a JSP file.
But the codings below don't work. Please advise me on how can i display the text file content.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File adCheck = new File("list.txt");
fis = new FileInputStream(adCheck);
int Length = adCheck.length();
byte arr[] = new byte[Length];
int dataRead = 0;
int totalData = 0;
while(totalData <Length)
dataRead = fis.read(arr,totalData,Length);
totalData += dataRead;
String Content = new String(arr);//byte array converted to String
arr = null;Take a BufferReader:
BufferedReader read = new BufferedReader(new FileReader("c:\test.txt");
String temp = read.readln();
You can make loops etc. Adding new Strings to an ArrayList,
adding Strings etc.... -
How to load the data from excel file into temprory table in Forms 11g?
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinDeclare
v_full_filename varchar2(500);
v_server_path varchar2(2000);
v_separator VARCHAR2(1);
v_filename VARCHAR2(400);
filename VARCHAR2 (100);
v_stop_load varchar2 (2000);
v_rec_error_log varchar2(4000);
v_error_log varchar2(4000);
ctr NUMBER (12);
cols NUMBER (2);
btn number;
RES BOOLEAN;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
cellType ole2.OBJ_TYPE;
args ole2.obj_type;
PROCEDURE olearg
IS
args ole2.obj_type;
BEGIN
args := ole2.create_arglist;
ole2.add_arg (args, ctr);
ole2.add_arg (args, cols);
cell := ole2.get_obj_property (worksheet, 'Cells', args);
ole2.destroy_arglist (args);
END;
BEGIN
v_full_filename := client_get_file_name(directory_name => null
,file_name => null
,file_filter => 'Excel files (*.xls)|*.xls|'
||'Excel files (*.xlsx)|*.xlsx|'
,message => 'Choose Excel file'
,dialog_type => null
,select_file => null
If v_full_filename is not null Then
v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
v_filename := v_separator||v_full_filename ;
:LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);
RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));
--Begin load data from EXCEL
BEGIN
filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
application := ole2.create_obj ('Excel.Application');
ole2.set_property (application, 'Visible', 'false');
workbooks := ole2.get_obj_property (application, 'Workbooks');
args := ole2.create_arglist;
ole2.add_arg (args, filename); -- file path and name
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'Sheet1');
worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
ole2.destroy_arglist (args);
ctr := 2; --row number
cols := 1; -- column number
go_block('xxx');
FIRST_RECORD;
LOOP
--Column 1 VALUE --------------------------------------------------------------------
olearg;
v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
:item1 := v_stop_load;
cols := cols + 1;
--Column 2 VALUE --------------------------------------------------------------------
olearg;
:item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
cols := cols + 1;
--<and so on>
ole2.invoke (application, 'Quit');
ole2.RELEASE_OBJ (cell);
ole2.RELEASE_OBJ (worksheet);
ole2.RELEASE_OBJ (worksheets);
ole2.RELEASE_OBJ (workbook);
ole2.RELEASE_OBJ (workbooks);
ole2.RELEASE_OBJ (application);
END;
--End load data from EXCELPlease mark it as answered if you helped. -
How to import data from a text file into a table
Hello,
I need help with importing data from a .csv file with comma delimiter into a table.
I've been struggling to figure out how to use the "Import from Files" wizard in Oracle 10g web-base Enterprise Manager.
I have not been able to find a simple instruction on how to use the Wizard.
I have looked at the Oracle Database Utilities - Overview of Oracle Data Pump and the Help on the "Import: Files" page.
Neither one gave me enough instruction to be able to do the import successfully.
Using the "Import from file" wizard, I created a Directory Object using the Create Directory Object button. I Copied the file from which i needed to import the data into the Operating System Directory i had defined in the Create Directory Object page. I chose "Entire files" for the Import type.
Step 1 of 4 is the "Import:Re-Mapping" page, I have no idea what i need to do on this page. All i know i am not tying to import data that was in one schema into a different schema and I am not importing data that was in one tablespace into a different tablespace and i am not R-Mapping datafiles either. I am importing data from a csv file.
For step 2 of 4, "Import:Options" page, I selected the same directory object i had created.
For step 3 of 4, I entered a job name and a description and selected Start Immediately option.
What i noticed going through the wizard, the wizard never asked into which table do i want to import the data.
I submitted the job and I got ORA-31619 invalid dump file error.
I was sure that the wizard was going to fail when it never asked me into which table do i want to import the data.
I tried to use the "imp" utility in command-line window.
After I entered (imp), i was prompted for the username and the password and then the buffer size as soon as i entered the min buffer size I got the following error and the import was terminated:
C:\>imp
Import: Release 10.1.0.2.0 - Production on Fri Jul 9 12:56:11 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Username: user1
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Import file: EXPDAT.DMP > c:\securParms\securParms.csv
Enter insert buffer size (minimum is 8192) 30720> 8192
IMP-00037: Character set marker unknown
IMP-00000: Import terminated unsuccessfully
Please show me the easiest way to import a text file into a table. How complex could it be to do a simple import into a table using a text file?
We are testing our application against both an Oracle database and a MSSQLServer 2000 database.
I was able to import the data into a table in MSSQLServer database and I can say that anybody with no experience could easily do an export/import in MSSQLServer 2000.
I appreciate if someone could show me how to the import from a file into a table!
Thanks,
Mitra>
I can say that anybody with
no experience could easily do an export/import in
MSSQLServer 2000.
Anybody with no experience should not mess up my Oracle Databases ! -
Hi,
I want to load a file which is comma separated and contain address .Problem is that address its self comma seprated so how do I differenciate whether comma used for column seprator or it used in address.
for eg.
One person having address like
"c/o AB corp,156 cross lane,USA"
Thanks.....Hi SR_MCTS,
Based on your description, you want to distinguish a comma is used for column separator or used in address column in a text file, then load the data from the text file to SQL Server table.
As per my understanding, if you can replace the comma column separator to another delimiter like semicolon (;), just do it. Then we can select Semicolon {;} as Column delimiter for the Flat File Connection Manager. Or ensure all columns are enclosed in double
quotes ("). Then we can set the double quotes (") as Text qualifier for the Flat File Connection Manager, and the commas will be loaded as part of the string fields.
If you can't have that done, because computers don't know the context of the data, you would have to come up with some kind of rules that decides when a comma represents a delimiter, and when it is just part of the text. I think a custom script component
would be necessary to pre-process the data, identify where a comma is part of an address, and then treat that as one field.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to compare content of two text file using StreamTokenizer
hi....
i have two text files...containg field like(name,number,scheme) and(number,date,value)... i want to create a third file containg field like (name,number,date,scheme,value) by using these two table. how to createI think this code can solve your problem.
private static final String DELIM = ",";
* Compile two files.
* @param file1 String the input file 1
* @param file2 String the input file 2
* @param file3 String the output file
* @throws IOException error in reading/writing
public void compileFiles(String file1, String file2, String file3) throws
IOException {
BufferedReader reader1 = new BufferedReader(new InputStreamReader(
new FileInputStream(file1)));
BufferedReader reader2 = new BufferedReader(new InputStreamReader(
new FileInputStream(file2)));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file3)));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
while (line1 != null && line2 != null) {
writer.write(compileLines(line1, line2));
writer.newLine();
line1 = reader1.readLine();
line2 = reader2.readLine();
reader1.close();
reader2.close();
writer.close();
private String compileLines(String line1, String line2) {
StringTokenizer tok1 = new StringTokenizer(line1, DELIM);
StringTokenizer tok2 = new StringTokenizer(line2, DELIM);
String name = tok1.nextToken();
String number = tok1.nextToken();
String scheme = tok1.nextToken();
// ignore number
tok2.nextToken();
String date = tok2.nextToken();
String value = tok2.nextToken();
StringBuffer buffer = new StringBuffer();
buffer.append(name);
buffer.append(DELIM);
buffer.append(number);
buffer.append(DELIM);
buffer.append(date);
buffer.append(DELIM);
buffer.append(scheme);
buffer.append(DELIM);
buffer.append(value);
return buffer.toString();
} -
Loading large text files into java vectors and outof memmory
Hi there,
need your help for the following:
i'm trying to load large ammoubnts of data into a Vector in order to concatenate several text files and treat them, but i'm getting outofmemory error. I even tried using xml structure and saving to database but the error is still the same. Can you help?
thanks
here's the code:
public void Concatenate() {
try {
//for(int i=0;i<1;i++) {
vEntries = new Vector();
for(int i=0;i<BopFiles.length;i++) {
MainPanel.WriteLog("reading file " + BopFiles[i] + "...");
FileInputStream fis = new FileInputStream(BopFiles);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream in = new DataInputStream(bis);
String line = in.readLine();
Database db = new Database();
Connection conn = db.open();
while(line != null) {
DivideLine(BopFiles[i], line);
line = in.readLine();
FreeMemory(db, conn);
MainPanel.WriteLog("Num of elements: " + root.getChildNodes().getLength());
MainPanel.WriteLog("Done!");
} catch (Exception e) {
e.printStackTrace();
public void DivideLine(String file, String line) {
if (line.toLowerCase().startsWith("00694")) {
Header hd = new Header();
hd.headerFile = file;
hd.headerLine = line;
vHeaders.add(hd);
} else if (line.toLowerCase().startsWith("10694")) {
Line entry = new Line();
Vector vString = new Vector();
Vector vType = new Vector();
Vector vValue = new Vector();
entry.name = line.substring(45, 150).trim();
entry.number = line.substring(30, 45).trim();
entry.nif = line.substring(213, 222).trim();
entry.index=BopIndex;
entry.message=line;
entry.file=file;
String series = line.substring(252);
StringTokenizer st = new StringTokenizer(series, "A");
while (st.hasMoreTokens()) {
String token=st.nextToken();
if(!token.startsWith(" ")) {
vString.add(token);
vType.add(token.substring(2,4));
vValue.add(token.substring(4));
token=null;
entry.strings= new String[vString.size()];
vString.copyInto(entry.strings);
entry.types= new String[vType.size()];
vType.copyInto(entry.types);
entry.values= new String[vType.size()];
vValue.copyInto(entry.values);
vEntries.add(entry);
entry=null;
vString=null;
vType=null;
vValue=null;
st=null;
series=null;
line=null;
file=null;
MainPanel.SetCount(BopIndex);
BopIndex ++;
public void FreeMemory(Database db, Connection conn) {
try {
//db.update("CREATE TABLE entries (message VARCHAR(1000))");
db.update("DELETE FROM entries;");
PreparedStatement ps = null;
for( int i=0; i<vEntries.size(); i++ ) {
Line entry = (Line) vEntries.get(i);
String value = "" + entry.message;
if(!value.equals("")) {
try {
ps = conn.prepareStatement("INSERT INTO entries (message) VALUES('" + Tools.RemoveSingleQuote(value) + "');");
ps.execute();
} catch(Exception e) {
e.printStackTrace();
System.out.println("error in number->" + i);
MainPanel.WriteLog("Releasing memory...");
vEntries = null;
vEntries = new Vector();
System.gc();
} catch (Exception e1) {
e1.printStackTrace();Well, i need to treat those contents, and calculate values withing those files, so wrinting files using FileInputstream wont do. for instance i need to get line 5 from file 1, split it, grab a value according to its class (value also taken) and compare it with another line of another file, adding those values to asingle file.
that's why i need vector capabilities, but since these files have more than 5 Mb each, an out of memory error is returned by loading those values into vector.
A better explanaition:
Each file has a line like
CLIENTNUM CLASS VALUE
so if the client is the same withing 2 files, i need to sum the lines into a single file.
If class is the same, then sum values, if not add it to the front.
we could have a final line like
CLIENTNUM CLASS1 VALUE1 CLASS2 VALUE2 -
How to get data of tabulated text file into internal table
hi all,
i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding how to convert excel file into internal table but i didnt get posts regarding text file.
thanks
SAchintry:
DATA: BEGIN OF tabulator,
x(1) TYPE x VALUE '09',
END OF tabulator.
READ DATASET file INTO wa.
split wa at tabulator into table itab.
A. -
How to export subtitles as a text file into DVDSP
Hi, I am trying to export subtitles from fcp 4.5 to dvdsp 3 as a .txt file. (Dvdsp can use .txt files in its subtitle track.)
I had already created all the subtitles in fcp, and I hope that there is a way where I do not have to create them again from scratch in dvdsp.
Thank you!Hi Hanumang,
So, I did the txt file piece by pice. It did not go into dvdsp perfectly; I had to shift some of the titles around a bit.
Now I have another problem which I jusdt posted.
Perhaps you can help me again?
New issue:
I now imported an improved (re-edited with a few brightness corrections) compressed file into DVDSP, deleted the previous file, dragged the new file into tracks in Dvdsp. (Let's call this project "new").
Now the subtitles from S1 have disappeared! (I had spend tons of time creating subtitles)
I did a new save, so, yesterdays DVDSP project (let's call this project "old") is still OK, with the perfect subtitles, but not-all-perfect video track (where I improved the brightness filter).
Can I re-import the subtitles from the "old" project into the "new" one? If yes, how?
Or, can I export the subtitles from "old" into a txt. file and then import it into project "new?"
Please help!
Thank you for your time!
Gabriele (without an intern -
How to do import data from the text file into the mathscript window?
Could anyone tell me how to do import data from text file into mathscript window for labview 8?
MathScript Window openned, File, Load Data - it has options: custom pattern (*.mlv) or all files.
ThanksHi Milan,
Prior to loading data in Mathscript Window , you have to save the data from the Mathscript window (the default extension of the file is .mlv but you can choose any extension). This means that you cannot load data from a text file that was not created using the Mathscript window.
Please let me know if you have any further questions regarding this issue.
Regards,
Ankita -
Error while loading data from a text file to a datastore
Hi all,
i am a starter in ODI. I am trying to load data from a text file into a datastore. I have put the file on a unix server whose location is defined in the topology manager. when i am trying to "view data" it is giving me error file does not exist at <location where i have put the file>. Please help meHi,
1. If your files are on a remote File System, you will need to copy one of your files to the machine ODI Designer is running on to allow ODI to retrieve the metadata information of the file.
2. In Topology create a Physical Schema, the directory you enter for Data and Work Schema should point at this local file.
3. Then define the File Datastore in ODI Designer. Enter a name, browse and select the file and fill in each filed of the Files tab.
* If its a Fixed file, click on the grid icon on the Columns tab to enter the columns and have Automatic Adjustment checked.
* If its a Delimited file, use the Reverse button on the Columns tab to reverse the columns.
* Right click on the File Datastore select View Data, if you can view data, that means the File Datastore has been defined correctly.
* If not, check each tab of the File Datastore to make sure everything is defined correctly and retry.
4. Once View Data is successful, you now change the directories (Data and Work Schema in Topology) to point at the remote File System. These directories must be accessible to the ODI Agent that will be used to run the transformations. The directory can be an absolute path (m:/public/data/files) or relative to the ODI Agent startup directory (../demo/files). It is strongly advised to use a UNC (independent from the execution location) for the path. When running the transformations with "no agent", the directory is relative to the directory where Oracle Data Integrator has been installed.
You need to have a agent process running at the system where your source file resides .
Then while running the odi interface choose that agent .
Thanks,
Sutirtha -
Convert a line read from text file into string
how to convert a line from text file into string?
i know how to convert to numbers,
private int parseLine1(String line) {
StringTokenizer tokenizer = new StringTokenizer(line);
value1 = Integer.valueOf(tokenizer.nextToken()).intValue();
value2 = Integer.valueOf(tokenizer.nextToken()).intValue();
return value1;
}but what about charactrs?ok, here is my problem, i have a file with a bunch of Xs in it but position function doesn't return a correct value, what's going wrong?
private int positioni(){
int i=0;
int j=0;
int b=0;
String line="";
while(line!= null){
for(int a=0; a<line.length(); a++){
if(line.charAt(a)=='X'){
i=a;}
b++;
j=b;
t=line.length();
line=read(gridFileN);
return i;
private String read(String ggridFileN){
TextStreamReader ggridFile = new TextStreamReader(ggridFileN);
return ggridFile.readLine(); -
How to load external text file into a Form?
Hi,
I made a menu with 1-5 in a Form and 5 external text files. I want the user who is able to view the text content of the text file when he chooses one of them from the menu. And the text file screen has a "Back" command button to let him go back.
How can I do it and can it support other languages such as Chinese and Japanese?
Thanks for help.
gogoSorry, I made the mistake about the subject, it should be loading local file, not external file through http.
I wrote a method but it throwed an exception when the midlet was run.
private void loadText()
try {
InputStream is = this.getClass().getResourceAsStream("/text.txt");
StringBuffer sb = new StringBuffer();
int chr;
while ((chr = is.read()) != -1)
sb.append((char) chr);
is.close();
catch (Exception e)
System.out.println("Error occurs while reading file");
I put the text.txt file in the same folder with the main file (extends midlet). How can I load the text content and display it on StringItem?
Thanks for any help.
gogo
Maybe you are looking for
-
Error while adding two facts in One SA
Hello Experts, I am new in OBIEE 11g. But with the concept of OBIEE 10g, I tried to work on 11g as well. Requirement: One subject area with two dimensions and two facts. In the warehouse we have 2 fact and 2 dimensions. Dim – Programme. Dim – Student
-
somebody help me in this?
-
ZAP_AGE - Vendor Payment History with OI Sorted List
Hi, I am suggesting this report to my client as Vendor ageing report. This report is calculating the overdue values from the document date of the vendor invoice, However, my client wants to calcuate the values from the Due date of the Invoice. Is the
-
Group by clause based on condition
tblScore contains score for each problem id problemID score 1 1 10 2 2 30 tblSubmission contains problem submissions for each user id user problemID accepted 1 UserA
-
Query Builder List of Report Names & their corresponding Folder Names
HI there, I have in excess of 6000 reports deployed in my Crystal system. I need to pull 2 sets of data: 1. I need a list of all report names & their corresponding folder names 2. I need a list of all report names & their corresponding folder names w