Txt file problem
Hi all :
would you mind tell me how to access txt file,but
txt like as Database format as following:
Name Ago tele
A 12 123456
B 13 123445
C 14 12334213
In this TXT file , I want to get Record 1 field 2
What method can I use that?
Thank you
Here's the tutorial on streams:
http://java.sun.com/docs/books/tutorial/essential/io/index.html
That's how you read it in, then you can use StreamTokenizer to parse out whatever you want. If you're having trouble getting all that to work, search this forum and the New to Java forum for tons of information, and if that doesn't help, post the code you have and someone will be glad to help.
Similar Messages
-
SO_NEW_DOCUMENT_ATT_SEND_API1 and txt file problem
Hi
I'm using FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending a txt file attachment, but the format of data is wrong.
U s e r : T F R A N C O
D a t e : 1 8 / 0 5 / 2 0 1 0
clear objpack-transf_bin.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
objpack-obj_descr = 'Document'.
objpack-doc_size = tab_lines * 255.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
Document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
Packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
Receivers = reclist
EXCEPTIONS
too_many_receivers = 1
Document_not_sent = 2
Document_type_not_exist = 3
Operation_no_authorization = 4
others = 99.
Thanks in advance.Hi Carlos
I've could delete space between letters but I need how to make for put new line in text format
USER:TFRANCO FECHA:25/05/2010.
Format must be:
USER:TFRANCO
FECHA:25/05/2010.
code:
DATA: hexa(1) TYPE c VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE hexa text-H02 SY-UNAME INTO objbin-line . APPEND objbin.
CONCATENATE hexa text-H03 SY-DATUM INTO objbin-line . APPEND objbin.
Thanks in advance. -
Saving characters with ASCII codes (128 - 256) into txt file problem
Hello,
I am saving a query results into a text file (test.txt) with this procedure:
BEGIN
OWA_UTIL.mime_header ('application/octet', FALSE);
HTP.p ('Content-Disposition: attachment; filename="TEST.TXT"');
OWA_UTIL.http_header_close;
for rec in (select sample_text from tmp)
loop
htp.prn ( chr(230) || rec.sample_text || utl_tcp.crlf);
end loop;
-- Send an error code so that the rest of the HTML does not render
HTMLDB_APPLICATION.g_unrecoverable_error := TRUE;
END;
How can I save characters with ascii codes from 128 - 256 into the output file? If I use chr() function, characters are missing in the output file.
Platform: Apex 4.2 on apex.oracle.comHi 1010398,
Some thoughts:
I assume you've counted the characters in the output and/or used a "hex" text editor so you KNOW these characters are not being written. Are they not written at all, or are blanks being substituted or are NULLs being substituted?
I couldn't find much documentation on htp.prn. Though, one place I found
htp.prn (cbuf IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL);Do you suppose it's affected by the character set used?
Howard -
Problem on reading and writing from from a *.txt file
I get Problem on reading and writing from from a *.txt file. The following is the read() method...
The software said the DataInputStream is depreciated. Can anyone help me please?
public void read()
File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
FileInputStream in = null;
String str = "";
try
in = new BufferedReader(file);
//in = new FileInputStream(file);
for(;;)
str = new BufferedReader(in).readLine();
//str = new DataInputStream(in).readLine();
if(str == null)
break;
System.out.print(str);
in.close();
catch(IOException e)
System.err.println("execution error: " +e);
}Thank you for your reply. I have made some change. However, there is an incompetable type found error.
in = new BufferedReader(new InputStreamReader(in));The following are all of the code.
public void read()
File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
FileInputStream in = null;
//BufferedReader in = null;
String str = "";
try
in = new BufferedReader(new InputStreamReader(in));
//in = new FileInputStream(file);
for(;;)
BufferedReader Bstr = new BufferedReader(new InputStreamReader(in));
//str = new BufferedReader(in).readLine();
//str = new DataInputStream(in).readLine();
if(str == null)
break;
System.out.print(str);
in.close();
catch(IOException e)
System.err.println("execution error: " +e); -
Problem when I upload txt files to the server
Hi, I have a problem when I try to upload files to the server, and I can't understand the fail.
My case is:
I have a jsp page where a from is.
This form is sended to a servlet that proccess its content and upload the attach file to the server.
It works correctly (it uploads the files, txt, xls and csv), the problem is when I try to upload a txt file like this, for example:
Depth Age
0 0,1
2 0,9
3 2
5 6
6 9
8 12
34 25
56 39
101 40When I verify the uploaded file, this one has a character extra of return of line (a small square). This character prevents me from working then correctly with the file, on having detected a column of more.
Which can be the problem?
The code I use to uploaded the file is:
try
MyConnection Objconnection = new MyConnection();
boolean isMultipart = FileUpload.isMultipartContent(req);
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Set overall request size constraint
upload.setSizeMax(1024*512); //524288 Bytes (512 KB)
// Parse the request
List items = upload.parseRequest(req);
// Process the uploaded items
Iterator iter = items.iterator();
String dat = new String();
String typeFile = new String();
while (iter.hasNext())
FileItem item = (FileItem) iter.next();
if (item.getFieldName().equals("typeFile") )
typeFile = item.getString();
if (!item.isFormField())
String fieldName = item.getFieldName();
String fileName = item.getName();
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
int numbers=0;
for(int i=fileName.length();(i=fileName.lastIndexOf('\\',i-1))>=0;)
numbers++;
String stringFile[] = fileName.split("\\\\");
HttpSession session = req.getSession(true);
String loginSesion = (String)session.getAttribute("UserLogin");
String newUserFolder = loginSesion;
File createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder);
if ("AgeModel".equals(typeFile))
createFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder);
if (!createFile.exists())
createFile.mkdir();
fileName = stringFile[numbers];
File uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/"+newUserFolder+"/"+fileName);
if ("AgeModel".equals(typeFile) )
uploadedFile = new File("/usr/local/tomcat/webapps/Usuarios/FilesUp/AgeModels/"+newUserFolder+"/"+fileName);
existe = Objconnection.existFile(fileName, typeFile, loginSesion);
if ( true == existe )
exito = false;
else
item.write(uploadedFile);
....// NOW REGISTER THE FILE IN TH DATA BASE
} // if (!item.isFormField())
} // WHILE ( iter.hasNext() )
catch(Exception e) {
out.println("Error de Aplicaci�n " + e.getMessage());
return exito;
...THANKSHi,
Sorry I am aware this question was posted way back, but I am having similar problem and haven't been able to find the fix yet.
So please let me known if you have got any ideas.
My problem is same that I have to upload a CSV file from Client Machine (Windows) to Unix Application Server.
I am using JSP method post and multipart/form-data (as in http://www.roseindia.net/jsp/file_upload/Sinle_upload.xhtml.shtml).
The file is uploaded fine but the problem is it displays carraige Return (^M) a square boxes on Unix file.
I can't ask user to convert file to Unox format before uploading. They just convert excel file to CSV and upload.
Is there any way I can get rid of these characters as I have to use this file further.
Sorry, I can't use any paid utility or tool for it.
I would appreciate if you could please help.
Thanks,
SW -
Problem with printing txt file
I have a problem with printing txt file. My code looks like :
String filename = something.txt";
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService[] services = PrintServiceLookup.lookupPrintServices(
flavor, null);
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(PrintQuality.DRAFT);
pras.add(new Copies(1));
pras.add(MediaSizeName.ISO_A4);
pras.add(Sides.ONE_SIDED);
pras.add(Chromaticity.MONOCHROME);
PrintService service = ServiceUI.printDialog(null, 200, 200,
services, services[0],
null,
pras);
if (service != null)
try
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
Thread.sleep(10000);
catch(FileNotFoundException e)
catch(PrintException e1)
catch(InterruptedException e2)
It doesn't work :(
What is my purpose: I would like to print .txt file but I would like to get PrintDialog where I can choose PrintQuality, Chromaticity etc. I found also that I should use DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST but I don't know how.
I will be very gratefull for help :)I tested it on 3 printers (different models of hp). 2 of them don't give me any error but when it started print priter stoped (just as it dosesn't have a paper), but 1 of them doesn't react (there were no errors), i thought tahat something was wrong with printers but when I change DocFlavor.INPUT_STREAM.AUTOSENSE to DocFlavor.GIF and filename to dog.gif it works so mybe there is another way to print txt file
-
Problem exporting '.txt' file size 23 KB and '.zip' file size 4 MB
I am using Apex 3.0 version screen to upload '.txt' file and '.zip' file containing images.
I can successfully export '.txt' file and '.zip' file containing images as long as '.txt' file size is < 23 KB and '.zip' file size < 4 MB from database table 'TBL_upload_file' to the OS directory on the server.
processing of Larger files (sizes 35 KB and 6 MB) produce following Error Message.
‘ORA-21560: argument 2 is null, invalid or out of range’ error.
Here is my code:
I am using following code to export Documents from database table 'TBL_upload_file' to the OS directory on the server.
create or replace procedure "PROC_LOAD_FILES_TO_FLDR_BYTES"
(pchr_text_file IN VARCHAR2,
pchr_zip_file IN VARCHAR2)
is
lzipfile varchar(100);
lzipname varchar(100);
sseq varchar(1000);
ldocname varchar(100);
lfile varchar(100);
-- loaddoc (p_file in number) as
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32000);
l_amount NUMBER := 32000;
l_pos NUMBER := 1;
l_blob BLOB;
l_blob_len NUMBER;
l_file_name varchar(200);
l_doc_name varchar(200);
a_file_name varchar (200);
end_pos NUMBER;
begin
-- Get LOB locator
SELECT blob_content,doc_name
INTO l_blob,l_file_name
FROM tbl_upload_file
WHERE DOC_NAME = pchr_text_file;
--get length of blob
l_blob_len := DBMS_LOB.getlength(l_blob);
-- save blob length to determine end position
end_pos:= l_blob_len;
-- Open the destination file.
-- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
l_file := UTL_FILE.fopen('BLOBS',l_file_name,'WB', 32760); --use write byte option supported in 10G
-- if small enough for a single write
IF l_blob_len < 32760 THEN
utl_file.put_raw(l_file,l_blob);
utl_file.fflush(l_file);
ELSE -- write in pieces
-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer);
utl_file.fflush(l_file); --flush pending data and write to the file
-- set the start position for the next cut
l_pos := l_pos + l_amount;
-- set the end position if less than 32000 bytes, here end_pos captures length of the document
end_pos := end_pos - l_amount;
IF end_pos < 32000 THEN
l_amount := end_pos;
END IF;
END LOOP;
END IF;
--- zip file
-- Get LOB locator to locate zip file
SELECT blob_content,doc_name
INTO l_blob,l_doc_name
FROM tbl_upload_file
WHERE DOC_NAME = pchr_zip_file;
l_blob_len := DBMS_LOB.getlength(l_blob);
-- save blob length to determine end position
end_pos:= l_blob_len;
-- Open the destination file.
-- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
l_file := UTL_FILE.fopen('BLOBS',l_doc_name,'WB', 32760); --use write byte option supported in 10G
-- if small enough for a single write
IF l_blob_len < 32760 THEN
utl_file.put_raw(l_file,l_blob);
utl_file.fflush(l_file); --flush out pending data to the file
ELSE -- write in pieces
-- Read chunks of the BLOB and write them to the file
-- until complete.
l_pos:=1;
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer);
UTL_FILE.fflush(l_file); --flush pending data and write to the file
l_pos := l_pos + l_amount;
-- set the end position if less than 32000 bytes, here end_pos contains length of the document
end_pos := end_pos - l_amount;
IF end_pos < 32000 THEN
l_amount := end_pos;
END IF;
END LOOP;
END IF;
-- Close the file.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
exception
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20214,'Screen fields cannot be blank, Proc_Load_Files_To_Fldr_BYTES.');
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR(-20215,'More than one record exist in the tbl_load_file table, Proc_Load_Files_To_Fldr_BYTES.');
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE_APPLICATION_ERROR(-20216,'Some other errors occurred, Proc_Load_Files_To_Fldr_BYTES.');
end;
I am new to the Oracle.
Any help to modify this scipt and resolve this problem will be greatly appreciated.
Thank you.Ask this question in the Apex forums. See Oracle Application Express (APEX)
Regards Nigel -
Hi
I have a shell cluster where I type different data for my file. Then I save this to txt file. The problem is when I want to open the file and use the data for the same shell cluster, which is now an indicator. Can someone help me with this??
Attachments:
Save_read.vi 84 KBHi Boris,
see the attached example. It is better if you insert your input data into the save event, because you then save the newest values.
Mike
Attachments:
Save_read_LV80.vi 91 KB -
Problem reading .txt-file into JTable
My problem is that I�m reading a .txt-file into a J-Table. It all goes okay, the FileChooser opens and the application reads the selected file (line). But then I get a Null Pointer Exception and the JTable does not get updated with the text from the file.
Here�s my code (I kept it simple, and just want to read the text from the .txt-file to the first cell of the table.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class TeamTable extends JFrame implements ActionListener, ItemListener {
static JTable table;
// constructor
public TeamTable() {
super( "Invoermodule - Team Table" );
setSize( 740, 365 );
// setting the rownames
ListModel listModel = new AbstractListModel() {
String headers[] = {"Team 1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6", "Team 7", "Team 8", "Team 9",
"Team 10", "Team 11", "Team 12", "Team 13", "Team 14", "Team 15", "Team 16", "Team 17", "Team 18"};
public int getSize() { return headers.length; }
public Object getElementAt(int index) { return headers[index]; }
// add listModel & rownames to the table
DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),3);
JTable table = new JTable( defaultModel );
// setting the columnnames and center alignment of table cells
int width = 200;
int[] vColIndex = {0,1,2};
String[] ColumnName = {"Name Team", "Name Chairman", "Name Manager"};
TableCellRenderer centerRenderer = new CenterRenderer();
for (int i=0; i < vColIndex.length;i++) {
table.getColumnModel().getColumn(vColIndex).setHeaderValue(ColumnName[i]);
table.getColumnModel().getColumn(vColIndex[i]).setPreferredWidth(width);
table.getColumnModel().getColumn(vColIndex[i]).setCellRenderer(centerRenderer);
table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
// force the header to resize and repaint itself
table.getTableHeader().resizeAndRepaint();
// create single component to add to scrollpane (rowHeader is JList with argument listModel)
JList rowHeader = new JList(listModel);
rowHeader.setFixedCellWidth(100);
rowHeader.setFixedCellHeight(table.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
// add to scroll pane:
JScrollPane scroll = new JScrollPane( table );
scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
getContentPane().add(scroll, BorderLayout.CENTER);
// add menubar, menu, menuitems with evenlisteners to the frame.
JMenuBar menubar = new JMenuBar();
setJMenuBar (menubar);
JMenu filemenu = new JMenu("File");
menubar.add(filemenu);
JMenuItem open = new JMenuItem("Open");
JMenuItem save = new JMenuItem("Save");
JMenuItem exit = new JMenuItem("Exit");
open.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
filemenu.add(open);
filemenu.add(save);
filemenu.add(exit);
filemenu.addItemListener(this);
// ActionListener for ActionEvents on JMenuItems.
public void actionPerformed(ActionEvent e) {
String open = "Open";
String save = "Save";
String exit = "Exit";
if (e.getSource() instanceof JMenuItem) {
JMenuItem source = (JMenuItem)(e.getSource());
String x = source.getText();
if (x == open) {
System.out.println("open file");
// create JFileChooser.
String filename = File.separator+"tmp";
JFileChooser fc = new JFileChooser(new File(filename));
// set default directory.
File wrkDir = new File("C:/Documents and Settings/Erwin en G-M/Mijn documenten/Erwin/Match Day");
fc.setCurrentDirectory(wrkDir);
// show open dialog.
int returnVal = fc.showOpenDialog(null);
File selFile = fc.getSelectedFile();
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
fc.getSelectedFile().getName());
try {
BufferedReader invoer = new BufferedReader(new FileReader(selFile));
String line = invoer.readLine();
System.out.println(line);
// THIS IS WHERE IT GOES WRONG, I THINK
table.setValueAt(line, 1, 1);
table.fireTableDataChanged();
catch (IOException ioExc){
if (x == save) {
System.out.println("save file");
if (x == exit) {
System.out.println("exit file");
// ItemListener for ItemEvents on JMenu.
public void itemStateChanged(ItemEvent e) {
String s = "Item event detected. Event source: " + e.getSource();
System.out.println(s);
public static void main(String[] args) {
TeamTable frame = new TeamTable();
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
frame.setVisible(true);
* Define the look/content for a cell in the row header
* In this instance uses the JTables header properties
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
* Constructor creates all cells the same
* To change look for individual cells put code in
* getListCellRendererComponent method
RowHeaderRenderer(JTable table) {
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
* Returns the JLabel after setting the text of the cell
public Component getListCellRendererComponent( JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this;My problem is that I�m reading a .txt-file into a J-Table. It all goes okay, the FileChooser opens and the application reads the selected file (line). But then I get a Null Pointer Exception and the JTable does not get updated with the text from the file.
Here�s my code (I kept it simple, and just want to read the text from the .txt-file to the first cell of the table.
A MORE READABLE VERSION !
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.util.*;
import java.lang.*;
import java.io.*;
public class TeamTable extends JFrame implements ActionListener, ItemListener {
static JTable table;
// constructor
public TeamTable() {
super( "Invoermodule - Team Table" );
setSize( 740, 365 );
// setting the rownames
ListModel listModel = new AbstractListModel() {
String headers[] = {"Team 1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6", "Team 7", "Team 8", "Team 9",
"Team 10", "Team 11", "Team 12", "Team 13", "Team 14", "Team 15", "Team 16", "Team 17", "Team 18"};
public int getSize() { return headers.length; }
public Object getElementAt(int index) { return headers[index]; }
// add listModel & rownames to the table
DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),3);
JTable table = new JTable( defaultModel );
// setting the columnnames and center alignment of table cells
int width = 200;
int[] vColIndex = {0,1,2};
String[] ColumnName = {"Name Team", "Name Chairman", "Name Manager"};
TableCellRenderer centerRenderer = new CenterRenderer();
for (int i=0; i < vColIndex.length;i++) {
table.getColumnModel().getColumn(vColIndex).setHeaderValue(ColumnName[i]);
table.getColumnModel().getColumn(vColIndex[i]).setPreferredWidth(width);
table.getColumnModel().getColumn(vColIndex[i]).setCellRenderer(centerRenderer);
table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
// force the header to resize and repaint itself
table.getTableHeader().resizeAndRepaint();
// create single component to add to scrollpane (rowHeader is JList with argument listModel)
JList rowHeader = new JList(listModel);
rowHeader.setFixedCellWidth(100);
rowHeader.setFixedCellHeight(table.getRowHeight());
rowHeader.setCellRenderer(new RowHeaderRenderer(table));
// add to scroll pane:
JScrollPane scroll = new JScrollPane( table );
scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
getContentPane().add(scroll, BorderLayout.CENTER);
// add menubar, menu, menuitems with evenlisteners to the frame.
JMenuBar menubar = new JMenuBar();
setJMenuBar (menubar);
JMenu filemenu = new JMenu("File");
menubar.add(filemenu);
JMenuItem open = new JMenuItem("Open");
JMenuItem save = new JMenuItem("Save");
JMenuItem exit = new JMenuItem("Exit");
open.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
filemenu.add(open);
filemenu.add(save);
filemenu.add(exit);
filemenu.addItemListener(this);
// ActionListener for ActionEvents on JMenuItems.
public void actionPerformed(ActionEvent e) {
String open = "Open";
String save = "Save";
String exit = "Exit";
if (e.getSource() instanceof JMenuItem) {
JMenuItem source = (JMenuItem)(e.getSource());
String x = source.getText();
if (x == open) {
System.out.println("open file");
// create JFileChooser.
String filename = File.separator+"tmp";
JFileChooser fc = new JFileChooser(new File(filename));
// set default directory.
File wrkDir = new File("C:/Documents and Settings/Erwin en G-M/Mijn documenten/Erwin/Match Day");
fc.setCurrentDirectory(wrkDir);
// show open dialog.
int returnVal = fc.showOpenDialog(null);
File selFile = fc.getSelectedFile();
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
fc.getSelectedFile().getName());
try {
BufferedReader invoer = new BufferedReader(new FileReader(selFile));
String line = invoer.readLine();
System.out.println(line);
// THIS IS WHERE IT GOES WRONG, I THINK
table.setValueAt(line, 1, 1);
table.fireTableDataChanged();
catch (IOException ioExc){
if (x == save) {
System.out.println("save file");
if (x == exit) {
System.out.println("exit file");
// ItemListener for ItemEvents on JMenu.
public void itemStateChanged(ItemEvent e) {
String s = "Item event detected. Event source: " + e.getSource();
System.out.println(s);
public static void main(String[] args) {
TeamTable frame = new TeamTable();
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit(0);
frame.setVisible(true);
* Define the look/content for a cell in the row header
* In this instance uses the JTables header properties
class RowHeaderRenderer extends JLabel implements ListCellRenderer {
* Constructor creates all cells the same
* To change look for individual cells put code in
* getListCellRendererComponent method
RowHeaderRenderer(JTable table) {
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
* Returns the JLabel after setting the text of the cell
public Component getListCellRendererComponent( JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this; -
Problem about writing txt file and utl_put_line
After some research on the internet I found the way how to writre files from Oracle 11g to a txt file.
I read that utl_put_line only holds 32k per line and adds a new line at the end of each row but my problem it´s that if I want to open the file with SQL Server :D it doesn't recognize the CRLF so there is no end line and the last column has the data from the next row. The files are created on Linux so if I open them on Windows i have to convert into DOS format but if I try to open that file with Excel everything works fine, so I was wondering if there is a limit of columns or number of characters that can be on a txt file.
There is my pl sql that I used to create my txt files:
-------------------CODE-----------------------------
declare
cursor r1 is
select * from dqstage.st_nomdetalle
where sistema = 'NOR'
and procesar = 0
and identidad=02;
cursor r2 ( p_parid number) is
select * from dqstage.st_nomsubdetalle
where par_id = p_parid
and procesar = 0
and sistema = 'NOR'
and substr(nombrearchivo,6,2)=02;
vcadena varchar2(4000);
--vcadena1 varchar2(4000);
vcadena1 clob;
vcadena2 long;
c number:=0;
vencabezados long;
archivo sys.utl_file.file_type;
begin
archivo:= SYS.UTL_FILE.FOPEN(location=>'UPEPE_DIR',filename=>'nor02.txt',open_mode=>'w',max_linesize=>32767);
vencabezados :='FILEID|NOMBREARCHIVO|TIPOREGISTRO|IDENTIFICADORREGISTRO|FECHAEMISIONPAGO|CLAVETIPONOMINA|CLAVECT|TURNOCT|RFC|CURP|NUMEMPLEADOESTATAL'
||'|NUMSEGURIDADSOCIAL|NOMBRECOMPLETO|NOMBRES|PRIMERAPELLIDO|SEGUNDOAPELLIDO|CODIGOPAGADURIA|IDORIGENPRESUPUESTALPLAZA|CLAVEPRESUPUESTAL|'
||'PARTIDAPRESUPUESTAL|CODIGOPAGO|CLAVEUNIDAD|CLAVESUBUNIDAD|CLAVECATEGORIA|HSM|NUMEROPLAZA|CLAVENIVELPUESTO|CLAVENIVELSUELDO|ZONAECONOMICA|'
||'PERCEPCIONNETA|CLABECUENTA|NUMEROCHEQUE|CLAVEMOTIVOPAGORETROACTIVO|NUMTOTALPERDED|ERRORES|'
||'TIPOCONCEPTO1|CONCEPTOPAGO1|MONTO1|PERIODODEL1|PERIODOAL1|FUENTEFINANCIAMIENTO1|ORIGEN1|ERRORES1|'
||'TIPOCONCEPTO2|CONCEPTOPAGO2|MONTO2|PERIODODEL2|PERIODOAL2|FUENTEFINANCIAMIENTO2|ORIGEN2|ERRORES2|'
||'TIPOCONCEPTO3|CONCEPTOPAGO3|MONTO3|PERIODODEL3|PERIODOAL3|FUENTEFINANCIAMIENTO3|ORIGEN3|ERRORES3|'
||'TIPOCONCEPTO4|CONCEPTOPAGO4|MONTO4|PERIODODEL4|PERIODOAL4|FUENTEFINANCIAMIENTO4|ORIGEN4|ERRORES4|'
||'TIPOCONCEPTO5|CONCEPTOPAGO5|MONTO5|PERIODODEL5|PERIODOAL5|FUENTEFINANCIAMIENTO5|ORIGEN5|ERRORES5|'
||'TIPOCONCEPTO6|CONCEPTOPAGO6|MONTO6|PERIODODEL6|PERIODOAL6|FUENTEFINANCIAMIENTO6|ORIGEN6|ERRORES6|'
||'TIPOCONCEPTO7|CONCEPTOPAGO7|MONTO7|PERIODODEL7|PERIODOAL7|FUENTEFINANCIAMIENTO7|ORIGEN7|ERRORES7|'
||'TIPOCONCEPTO8|CONCEPTOPAGO8|MONTO8|PERIODODEL8|PERIODOAL8|FUENTEFINANCIAMIENTO8|ORIGEN8|ERRORES8|'
||'TIPOCONCEPTO9|CONCEPTOPAGO9|MONTO9|PERIODODEL9|PERIODOAL9|FUENTEFINANCIAMIENTO9|ORIGEN9|ERRORES9|'
||'TIPOCONCEPTO10|CONCEPTOPAGO10|MONTO10|PERIODODEL10|PERIODOAL10|FUENTEFINANCIAMIENTO10|ORIGEN10|ERRORES10|'
||'TIPOCONCEPTO11|CONCEPTOPAGO11|MONTO11|PERIODODEL11|PERIODOAL11|FUENTEFINANCIAMIENTO11|ORIGEN11|ERRORES11|'
||'TIPOCONCEPTO12|CONCEPTOPAGO12|MONTO12|PERIODODEL12|PERIODOAL12|FUENTEFINANCIAMIENTO12|ORIGEN12|ERRORES12|'
||'TIPOCONCEPTO13|CONCEPTOPAGO13|MONTO13|PERIODODEL13|PERIODOAL13|FUENTEFINANCIAMIENTO13|ORIGEN13|ERRORES13|'
||'TIPOCONCEPTO14|CONCEPTOPAGO14|MONTO14|PERIODODEL14|PERIODOAL14|FUENTEFINANCIAMIENTO14|ORIGEN14|ERRORES14|'
||'TIPOCONCEPTO15|CONCEPTOPAGO15|MONTO15|PERIODODEL15|PERIODOAL15|FUENTEFINANCIAMIENTO15|ORIGEN15|ERRORES15|'
||'TIPOCONCEPTO16|CONCEPTOPAGO16|MONTO16|PERIODODEL16|PERIODOAL16|FUENTEFINANCIAMIENTO16|ORIGEN16|ERRORES16|'
||'TIPOCONCEPTO17|CONCEPTOPAGO17|MONTO17|PERIODODEL17|PERIODOAL17|FUENTEFINANCIAMIENTO17|ORIGEN17|ERRORES17|'
||'TIPOCONCEPTO18|CONCEPTOPAGO18|MONTO18|PERIODODEL18|PERIODOAL18|FUENTEFINANCIAMIENTO18|ORIGEN18|ERRORES18|'
||'TIPOCONCEPTO19|CONCEPTOPAGO19|MONTO19|PERIODODEL19|PERIODOAL19|FUENTEFINANCIAMIENTO19|ORIGEN19|ERRORES19|'
||'TIPOCONCEPTO20|CONCEPTOPAGO20|MONTO20|PERIODODEL20|PERIODOAL20|FUENTEFINANCIAMIENTO20|ORIGEN20|ERRORES20|'
||'TIPOCONCEPTO21|CONCEPTOPAGO21|MONTO21|PERIODODEL21|PERIODOAL21|FUENTEFINANCIAMIENTO21|ORIGEN21|ERRORES21|'
||'TIPOCONCEPTO22|CONCEPTOPAGO22|MONTO22|PERIODODEL22|PERIODOAL22|FUENTEFINANCIAMIENTO22|ORIGEN22|ERRORES22|'
||'TIPOCONCEPTO23|CONCEPTOPAGO23|MONTO23|PERIODODEL23|PERIODOAL23|FUENTEFINANCIAMIENTO23|ORIGEN23|ERRORES23|'
||'TIPOCONCEPTO24|CONCEPTOPAGO24|MONTO24|PERIODODEL24|PERIODOAL24|FUENTEFINANCIAMIENTO24|ORIGEN24|ERRORES24|'
||'TIPOCONCEPTO25|CONCEPTOPAGO25|MONTO25|PERIODODEL25|PERIODOAL25|FUENTEFINANCIAMIENTO25|ORIGEN25|ERRORES25|'
||'TIPOCONCEPTO26|CONCEPTOPAGO26|MONTO26|PERIODODEL26|PERIODOAL26|FUENTEFINANCIAMIENTO26|ORIGEN26|ERRORES26|'
||'TIPOCONCEPTO27|CONCEPTOPAGO27|MONTO27|PERIODODEL27|PERIODOAL27|FUENTEFINANCIAMIENTO27|ORIGEN27|ERRORES27|'
||'TIPOCONCEPTO28|CONCEPTOPAGO28|MONTO28|PERIODODEL28|PERIODOAL28|FUENTEFINANCIAMIENTO28|ORIGEN28|ERRORES28|'
||'TIPOCONCEPTO29|CONCEPTOPAGO29|MONTO29|PERIODODEL29|PERIODOAL29|FUENTEFINANCIAMIENTO29|ORIGEN29|ERRORES29|'
||'TIPOCONCEPTO30|CONCEPTOPAGO30|MONTO30|PERIODODEL30|PERIODOAL30|FUENTEFINANCIAMIENTO30|ORIGEN30|ERRORES30|'
||'TIPOCONCEPTO31|CONCEPTOPAGO31|MONTO31|PERIODODEL31|PERIODOAL31|FUENTEFINANCIAMIENTO31|ORIGEN31|ERRORES31|'
||'TIPOCONCEPTO32|CONCEPTOPAGO32|MONTO32|PERIODODEL32|PERIODOAL32|FUENTEFINANCIAMIENTO32|ORIGEN32|ERRORES32|'
||'TIPOCONCEPTO33|CONCEPTOPAGO33|MONTO33|PERIODODEL33|PERIODOAL33|FUENTEFINANCIAMIENTO33|ORIGEN33|ERRORES33|'
||'TIPOCONCEPTO34|CONCEPTOPAGO34|MONTO34|PERIODODEL34|PERIODOAL34|FUENTEFINANCIAMIENTO34|ORIGEN34|ERRORES34|'
||'TIPOCONCEPTO35|CONCEPTOPAGO35|MONTO35|PERIODODEL35|PERIODOAL35|FUENTEFINANCIAMIENTO35|ORIGEN35|ERRORES35|'
||'TIPOCONCEPTO36|CONCEPTOPAGO36|MONTO36|PERIODODEL36|PERIODOAL36|FUENTEFINANCIAMIENTO36|ORIGEN36|ERRORES36|'
||'TIPOCONCEPTO37|CONCEPTOPAGO37|MONTO37|PERIODODEL37|PERIODOAL37|FUENTEFINANCIAMIENTO37|ORIGEN37|ERRORES37|'
||'TIPOCONCEPTO38|CONCEPTOPAGO38|MONTO38|PERIODODEL38|PERIODOAL38|FUENTEFINANCIAMIENTO38|ORIGEN38|ERRORES38|'
||'TIPOCONCEPTO39|CONCEPTOPAGO39|MONTO39|PERIODODEL39|PERIODOAL39|FUENTEFINANCIAMIENTO39|ORIGEN39|ERRORES39|'
||'TIPOCONCEPTO40|CONCEPTOPAGO40|MONTO40|PERIODODEL40|PERIODOAL40|FUENTEFINANCIAMIENTO40|ORIGEN40|ERRORES40|'
||'TIPOCONCEPTO41|CONCEPTOPAGO41|MONTO41|PERIODODEL41|PERIODOAL41|FUENTEFINANCIAMIENTO41|ORIGEN41|ERRORES41|'
||'TIPOCONCEPTO42|CONCEPTOPAGO42|MONTO42|PERIODODEL42|PERIODOAL42|FUENTEFINANCIAMIENTO42|ORIGEN42|ERRORES42|'
||'TIPOCONCEPTO43|CONCEPTOPAGO43|MONTO43|PERIODODEL43|PERIODOAL43|FUENTEFINANCIAMIENTO43|ORIGEN43|ERRORES43|'
||'TIPOCONCEPTO44|CONCEPTOPAGO44|MONTO44|PERIODODEL44|PERIODOAL44|FUENTEFINANCIAMIENTO44|ORIGEN44|ERRORES44|'
||'TIPOCONCEPTO45|CONCEPTOPAGO45|MONTO45|PERIODODEL45|PERIODOAL45|FUENTEFINANCIAMIENTO45|ORIGEN45|ERRORES45|'
||'TIPOCONCEPTO46|CONCEPTOPAGO46|MONTO46|PERIODODEL46|PERIODOAL46|FUENTEFINANCIAMIENTO46|ORIGEN46|ERRORES46|'
||'TIPOCONCEPTO47|CONCEPTOPAGO47|MONTO47|PERIODODEL47|PERIODOAL47|FUENTEFINANCIAMIENTO47|ORIGEN47|ERRORES47|'
||'TIPOCONCEPTO48|CONCEPTOPAGO48|MONTO48|PERIODODEL48|PERIODOAL48|FUENTEFINANCIAMIENTO48|ORIGEN48|ERRORES48|'
||'TIPOCONCEPTO49|CONCEPTOPAGO49|MONTO49|PERIODODEL49|PERIODOAL49|FUENTEFINANCIAMIENTO49|ORIGEN49|ERRORES49|'
||'TIPOCONCEPTO50|CONCEPTOPAGO50|MONTO50|PERIODODEL50|PERIODOAL50|FUENTEFINANCIAMIENTO50|ORIGEN50|ERRORES50';
--||'TIPOCONCEPTO51|CONCEPTOPAGO51|MONTO51|PERIODODEL51|PERIODOAL51|FUENTEFINANCIAMIENTO51|ORIGEN51|ERRORES51';
sys.utl_file.put_line(archivo, vencabezados);
for i in r1 loop
c:=c+1;
vcadena := i.fileid||'|'||i.nombrearchivo||'|'||i.tiporegistro||'|'||i.identificadorregistro||'|'||i.fechaemisionpago||'|'||i.clavetiponomina||'|'||i.clavect||'|'||i.turnoct||'|'||i.rfc
||'|'||i.curp||'|'||i.numempleadoestatal||'|'||i.numseguridadsocial||'|'||i.nombrecompleto||'|'||i.nombres||'|'||i.primerapellido||'|'||i.segundoapellido||'|'||i.codigopagaduria
||'|'||i.idorigenpresupuestalplaza||'|'||i.clavepresupuestal||'|'||i.partidapresupuestal||'|'||i.codigopago||'|'||i.claveunidad||'|'||i.clavesubunidad||'|'||i.clavecategoria||'|'||i.hsm
||'|'||i.numeroplaza||'|'||i.clavenivelpuesto||'|'||i.clavenivelsueldo||'|'||i.zonaeconomica||'|'||i.percepcionneta||'|'||i.clabecuenta||'|'||i.numerocheque||'|'||i.clavemotivopagoretroactivo
||'|'||i.numtotalperded||'|'||i.errores;
vcadena1:=null;
for j in r2 (i.fileid) loop
vcadena1 := vcadena1||'|'|| j.tipoconcepto||'|'||j.conceptopago||'|'||j.monto||'|'||j.periododel||'|'||j.periodoal||'|'||j.fuentefinanciamiento ||'|'||j.origen||'|'||j.errores;
end loop;
sys.utl_file.put_line(archivo, vcadena2);
end loop;
sys.utl_file.fclose(archivo);
end;
As you can see I write the column names first and with a loop I add the data, so I can have a very large column at the end.
How can I add the CRLF at the end of each line to have it working with Windows?user2068122 wrote:
After some research on the internet I found the way how to writre files from Oracle 11g to a txt file.
I read that utl_put_line only holds 32k per line and adds a new line at the end of each row but my problem it´s that if I want to open the file with SQL Server :D it doesn't recognize the CRLF so there is no end line and the last column has the data from the next row. The files are created on Linux so if I open them on Windows i have to convert into DOS format but if I try to open that file with Excel everything works fine, so I was wondering if there is a limit of columns or number of characters that can be on a txt file.
<snip>
Oracle is simply passing a string of characters to the OS to be written to a file in the host OS's native text format. That format is different from Windows and nix. Windows will append a CR-LF pair to the end of the provided character string, as its end-of-record delimiter. nix will append only a CR (or is it LF?) as its end-of-record delimiter. This is purely and OS issue that Oracle knows or cares nothing about. It is also something that must always be kept in mind when passing files between *nix and Windows. -
Problems getting elements to work in a txt file within Flash.
Hello! I'm working on my band's new website and have been
searching many hours for answers to some problems I'm having with
txt files referenced as HTML in Flash.
Our site is
http://moumusic.com.
One of the problems is having an image as a link. For
instance, I have a photo and try to link a website to it:
quote:
<a href="
http://cdbaby.com/cd/motuniverse"
target="_blank"><img src="images/cdbaby.gif" width="100"
height="100"></a>
It works when loaded as an HTML file, but not when viewed in
the Flash site. The text file for this is at
http://moumusic.com/moualbum.txt.
The page comes up when you click the "MoU's First CD" link on
moumusic.com.
Next, I can't link to external media files. For instance, I
tried inserting the code:
quote:
<a href="
http://fusco-moore.com/videos/SongforCliff-2.wmv">Song
for Cliff Video Part 2</a>
. You can click the text (while viewing it as
part of the Flash site), but nothing happens. You can even copy the
shortcut, but you can't use the link properly.
Last, I want to put a PayPal Buy It Now button on one of the
pages. The link is pretty long:
quote:
<a
href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=producer%40wcjm%2ecom&it em_name=%22Masters%20of%20the%20Universe%22%20CD%20by%20MoU&amount=10%2e00&no_shipping=2&n o_note=1¤cy_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF%2d8">Buy
Now!</a>
. I heard that there's a 128 character limit for
links in Flash. Is there any way around this?
What about forms? PayPal has the option of doing a form for a
shopping cart. Flash won't even begin to recognize it when I just
drop the form code in there.
Well, thanks for the help in advance- hopefully this stuff
can be accomplished!
JimI assume you are using the Flash TextField object set to
render html.
First to understand is that the extent of html recognized is
limited and by
player version. That means you cannot use any HTML tag you
wish.
See
http://livedocs.macromedia.com/flash/8/main/00001459.html
for the
supported list in Flash Player 8
You might check "About making hypertext links out of embedded
media " as
well:
http://livedocs.macromedia.com/flash/8/main/00001477.html
Malformed html in a TextField can render any tag in the field
non
functional. Be sure the html in the TextField is validated.
I would assume the anchor tag in Flash text field would
follow the same
rules an anchor tag in HTML as to length of the query string.
Finally consider using Flash with a button and getURL for the
PayPal link.
http://livedocs.macromedia.com/flash/8/main/00001730.html
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"wcjmproducer" <[email protected]> wrote in
message
news:[email protected]...
> Hello! I'm working on my band's new website and have
been searching many
> hours
> for answers to some problems I'm having with txt files
referenced as HTML
> in
> Flash.
>
> Our site is
http://moumusic.com.
>
> One of the problems is having an image as a link. For
instance, I have a
> photo and try to link a website to it:
>
>
quote:
<a href="
http://cdbaby.com/cd/motuniverse"
target="_blank"><img
> src="images/cdbaby.gif" width="100"
height="100"></a>
>
> It works when loaded as an HTML file, but not when
viewed in the Flash
> site.
> The text file for this is at
http://moumusic.com/moualbum.txt.
The page
> comes
> up when you click the "MoU's First CD" link on
moumusic.com.
>
> Next, I can't link to external media files. For
instance, I tried
> inserting
> the code:
quote:
<a
> href="
http://fusco-moore.com/videos/SongforCliff-2.wmv">Song
> for Cliff Video Part 2</a>
. You can click the text (while viewing it
> as
> part of the Flash site), but nothing happens. You can
even copy the
> shortcut,
> but you can't use the link properly.
>
> Last, I want to put a PayPal Buy It Now button on one of
the pages. The
> link
> is pretty long:
quote:
<a
>
href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=producer%40wcjm
>
%2ecom&item_name=%22Masters%20of%20the%20Universe%22%20CD%20by%20MoU&amount=10%2
>
e00&no_shipping=2&no_note=1¤cy_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF
> %2d8">Buy Now!</a>
. I heard that there's a 128 character limit for
> links
> in Flash. Is there any way around this?
>
> What about forms? PayPal has the option of doing a form
for a shopping
> cart.
> Flash won't even begin to recognize it when I just drop
the form code in
> there.
>
> Well, thanks for the help in advance- hopefully this
stuff can be
> accomplished!
>
> Jim
> -
Problem with RSCRM_BAPI (extraction to Fixed Lenght txt file)
Hi Experts,
I have a question about a RSCRM_BAPI limitation:
I want to extract a Query, using this transaction, to a fixed lenght .txt file. The query has a tabular structure like this:
CHARACT1 | CHARACT2 | CHARACT3 | CHARACT4 | KEYFIG_MONTH1 | KEYFIG_MONTH2 | .... | KEYFIG_MONTH12.
so i have a tabular structure with some CH and a KF repeated for the 12 month of the year.
The problem is that the fixed lenght .txt file extracted with RSCRM_BAPI stops to the month 11, month 12 is discarded. If i try to extract a .csv file with the same query all the 12 month are included in the file.
Question: Is it possible that RSCRM_BAPI has a row lenght limitation considering the fixed lenght .txt file?
Many thanks in advance.
FabioHow did you sechudle the Query/Report Using BAPI, i'm having similar Problem. Please Can you help me out.
My problem is , i have a query which is schedule for every month 2 wed and a bapi is associated to The query.
for some reason's the query is not working properly .
Can you please help. -
Also problem read txt files into JTable
hello,
i used the following method to load a .txt file into JTable
try{
FileInputStream fin = new FileInputStream(filename);
InputStreamReader isr = new InputStreamReader(fin);
BufferedReader br = new BufferedReader(isr);
StringTokenizer st1 = new StringTokenizer(br.readLine(), "|");
while( st1.hasMoreTokens() )
columnNames.addElement(st1.nextToken());
while ((aLine = br.readLine()) != null)
StringTokenizer st2 = new StringTokenizer(aLine, "|");
Vector row = new Vector();
while(st2.hasMoreTokens())
row.addElement(st2.nextToken());
data.addElement( row );
br.close();
}catch(Exception e){ e.printStackTrace(); }
//colNum = st1.countTokens();
model = new DefaultTableModel(data,columnNames);
table.setModel(model);but there is a problem : if cell A's location is (4,5),and its left neighbour,that is, cell(4,4) is blank (the value is ""), the the cell A's value will be displayed in cell(4,4).if cell(4,3) is also blank ,the cell A's value will be displayed in cell(4,3).that is,the non-blank value will be displayed in the first blank cell of the line.
how can i solve it?Please give me some helps or links.
Thank u very much!Or, use the String.split(..) method to tokenize the data
Or, use my SimpleTokenizer class which you can find by using the search function. -
Problem exporting txt' file size is 23 KB and '.zip' size 4 MB
I am using Apex 3.0 version screen to upload '.txt' file and '.zip' file containing images.
I can successfully export '.txt' file and '.zip' file containing images as long as '.txt' file size is < 23 KB and '.zip' file size < 4 MB from database table 'TBL_upload_file' to the OS directory on the server.
processing of Larger files (sizes 35 KB and 6 MB) produce following Error Message.
‘ORA-21560: argument 2 is null, invalid or out of range’ error.
Here is my code:
I am using following code to export Documents from database table 'TBL_upload_file' to the OS directory on the server.
create or replace procedure "PROC_LOAD_FILES_TO_FLDR_BYTES"
(pchr_text_file IN VARCHAR2,
pchr_zip_file IN VARCHAR2)
is
lzipfile varchar(100);
lzipname varchar(100);
sseq varchar(1000);
ldocname varchar(100);
lfile varchar(100);
-- loaddoc (p_file in number) as
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32000);
l_amount NUMBER := 32000;
l_pos NUMBER := 1;
l_blob BLOB;
l_blob_len NUMBER;
l_file_name varchar(200);
l_doc_name varchar(200);
a_file_name varchar (200);
end_pos NUMBER;
begin
-- Get LOB locator
SELECT blob_content,doc_name
INTO l_blob,l_file_name
FROM tbl_upload_file
WHERE DOC_NAME = pchr_text_file;
--get length of blob
l_blob_len := DBMS_LOB.getlength(l_blob);
-- save blob length to determine end position
end_pos:= l_blob_len;
-- Open the destination file.
-- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
l_file := UTL_FILE.fopen('BLOBS',l_file_name,'WB', 32760); --use write byte option supported in 10G
-- if small enough for a single write
IF l_blob_len < 32760 THEN
utl_file.put_raw(l_file,l_blob);
utl_file.fflush(l_file);
ELSE -- write in pieces
-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer);
utl_file.fflush(l_file); --flush pending data and write to the file
-- set the start position for the next cut
l_pos := l_pos + l_amount;
-- set the end position if less than 32000 bytes, here end_pos captures length of the document
end_pos := end_pos - l_amount;
IF end_pos < 32000 THEN
l_amount := end_pos;
END IF;
END LOOP;
END IF;
--- zip file
-- Get LOB locator to locate zip file
SELECT blob_content,doc_name
INTO l_blob,l_doc_name
FROM tbl_upload_file
WHERE DOC_NAME = pchr_zip_file;
l_blob_len := DBMS_LOB.getlength(l_blob);
-- save blob length to determine end position
end_pos:= l_blob_len;
-- Open the destination file.
-- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
l_file := UTL_FILE.fopen('BLOBS',l_doc_name,'WB', 32760); --use write byte option supported in 10G
-- if small enough for a single write
IF l_blob_len < 32760 THEN
utl_file.put_raw(l_file,l_blob);
utl_file.fflush(l_file); --flush out pending data to the file
ELSE -- write in pieces
-- Read chunks of the BLOB and write them to the file
-- until complete.
l_pos:=1;
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer);
UTL_FILE.fflush(l_file); --flush pending data and write to the file
l_pos := l_pos + l_amount;
-- set the end position if less than 32000 bytes, here end_pos contains length of the document
end_pos := end_pos - l_amount;
IF end_pos < 32000 THEN
l_amount := end_pos;
END IF;
END LOOP;
END IF;
-- Close the file.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
exception
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20214,'Screen fields cannot be blank, Proc_Load_Files_To_Fldr_BYTES.');
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR(-20215,'More than one record exist in the tbl_load_file table, Proc_Load_Files_To_Fldr_BYTES.');
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE_APPLICATION_ERROR(-20216,'Some other errors occurred, Proc_Load_Files_To_Fldr_BYTES.');
end;
I am new to the Oracle.
Any help to modify this scipt and resolve this problem will be greatly appreciated.
Thank you.Ask this question in the Apex forums. See Oracle Application Express (APEX)
Regards Nigel -
Problem of reading the content of this .txt files
currently i have a problem of reading the content of this file castle.txt
#Server Ready.
Lee Siaw Kang 50256808:08:382004/03/15Abdul Rahman 60296008:13:242004/03/15Kenneth Lee 60299308:13:532004/03/15Ho Kid Peng 31337508:17:442004/03/15Tonny Sherbern 50271108:19:132004/03/15Frederick Foh 50257908:20:212004/03/15Jason Kho 61702908:21:312004/03/15Lois Lee Liarn Huee 61897408:22:522004/03/15Victor Palau Udih 31337308:23:202004/03/15Michelle Sim 61899008:27:412004/03/15Alan Hong 50262708:30:312004/03/15Frederick Foh 50257908:33:412004/03/15Douglas Aseng 50255808:36:442004/03/15Atika Abang 31347508:36:592004/03/15David Dzrandinuraidi 61239608:38:012004/03/15Sentia Brangking 61896808:39:502004/03/15Dinah Samuel 61704608:40:582004/03/15Dr. Anderson Tiong 61702508:42:102004/03
it is something like this ...i want to break it into readable format ...i have tried vector with is the following code.
import java.util.*;
import java.io.*;
public class parseCastle {
public static Vector parseInfo(String str) {
int recordSize = 59;
Vector v = new Vector();
for (int i=0; i<str.length(); i+=recordSize) {
String str1 = str.substring(i, i+recordSize);
Vector vi = new Vector();
vi.addElement(str1.substring(0, 35));
vi.addElement(str1.substring(35, 41));
vi.addElement(str1.substring(41, 49));
vi.addElement(str1.substring(49, 59));
v.addElement(vi);
return v;
//constructor
parseCastle(){
try
FileInputStream fin = new FileInputStream("castle.txt");
File fprop = new File("castle.txt");
byte[] data = new byte[(int)fprop.length()];
int total = fin.read(data);
if (total != data.length) {
System.err.println("Error loading file");
return;
//System.out.println(data.length);
Vector v = parseInfo(new String(data));
for (int i=0; i<v.size(); i++) {
Vector vi = (Vector)v.elementAt(i);
for (Enumeration e = vi.elements(); e.hasMoreElements();)
System.out.println(e.nextElement());
System.out.println();
//*** Alternative ***
//for (int k=0; k<vi.size(); k++)
// System.out.println(vi.elementAt(k));
catch (IOException e)
System.out.println("Error: "+e);
e.printStackTrace();
But it gave me error. like it exceeds array boundary...can someone expert help me outYou should be aware that these kind of effort always involves certain amount of risk because the proper record format is not hundred percent guaranteed. So, make sure to use properly formatted file, or genuine database instead.
import java.io.*;
import java.util.regex.*;
public class ParseCastle2{
public static void main(String[] args) throws Exception{
String line, data;
BufferedReader br = new BufferedReader(new FileReader("castle.txt"));
br.readLine(); //discard #Server Ready line
line = br.readLine();
Pattern pat = Pattern.compile("([ .A-Za-z]+)([/0-9:]+)");
Matcher mat = pat.matcher(line);
Pattern subPat = Pattern.compile("(\\d+):(\\d\\d:\\d\\d)(.+)");
while (mat.find()){
System.out.println(mat.group()); // if name only, use group(1) ... beware trailing space
data = mat.group(2);
Matcher subMat = subPat.matcher(data);
while (subMat.find()){
System.out.println(" cdID = " + subMat.group(1));
System.out.println(" Time = " + subMat.group(2));
System.out.println(" Date = " + subMat.group(3));
Maybe you are looking for
-
Internet connection suddenly slow for iMac but OK for iPad and iPod
A few days ago the WIFI internet connection on my iMac suddenly became so slow as to be unusable. However my iPad and iPod Touch on the same network still connect as normal. I have tried everything I can think of together with some ideas posted on v
-
Yosemite won't recognise CanonMG7150 - please help!
Had a problem with my internet connection, restored it, and now suddenly I can't print. I am running 10.10.3. I removed the printer from the list, and tried to add it as new, including reinstalling the drivers downloaded from Canon. The printer says
-
Entry using connection AFW failed
Hi, I am trying to read an external file and push it in to R/3 by calling RFC using XI. I configured everything. File and RFC adapters are working fine. After processing as per settings it is deleting the file but it is not pushing in to R/3. In the
-
Theme Editor displaying blank screen
Hi, I am having SAP NetWeaver 7.0 (2004s). when i login with adminstrator ,2 weeks back i am able to see the Theme Editor with all the Themes but now i am NOT able to see anything. Its just displaying blank screen. Please let me know how i will get t
-
Converting tables in Pages to Address Book entries.
I created a photo directory using seperate tables (81 of them) in Pages. Each table has a picture, contact info, and then other things like hobbies, job, birthdays, etc. Can I convert these to individual contacts in address book?