Clearing text file content?
BufferedWriter w = new BufferedWriter(new FileWriter("index.txt"));
w.write("");is this the way to delete text in a file???
i want to clear a text file from all characters.
thank you for your help
BufferedWriter w = new BufferedWriter(new
FileWriter("index.txt"));
w.write("");
is this the way to delete text in a file???
i want to clear a text file from all characters.Call the FileWriter constructor with a boolean append argument set to false. It will create a new file overwriting the previous one.
BufferedWriter w = new BufferedWriter(new FileWriter("index.txt", false));
Similar Messages
-
How to read text file content in portal application?
Hi,
How do we read text file content in portal application?
Can anyone forward the code to do do?
Regards,
AnaghaCheck the code below. This help you to know how to read the text file content line by line. You can display as you require.
IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
IResourceContext resourceContext = new ResourceContext(user);
String filePath = "/documents/....";
RID rid = RID.getRID(filePath);
IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
InputStream inputStream = resource.getContent().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = reader.readLine();
while(line!=null) {
line = reader.readLine();
//You can append in string buffer to get file content as string object//
Regards,
Yoga -
Need to read text file content and have to display it in multiline text box
dear all,
Need to read text file content and have to display it in multiline text box.
actually im new to file handling. i have tried up to get_line and put_line.
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
i dont know how to assign this get_line function to text item
pls help me in this regards,Simply write:
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
:block2.t1 := chr(10)||:block2.t1||chr(10)||linebuf;
chr(10) --> is for new line character -
How to convert a text file content to String in JSP?
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;InputStreamReader in=new InputStreamReader(fis);
StringWriter out=new StringWriter();
char[] buffer=new char[8192];
int sizeRead;
while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
out.write(buffer, 0, sizeRead);
String content=out.toString(); -
Verification of text file content without using AUT
The AUT is generating a text file. The text file can not be opened in the AUT.
How can I verify the content of the text file (e. g. with regular expressions)?You may use read-lines command.
It reads lines and writes them one-by-one to output pipe.
Please try and let me know if you have any questions. -
Turn a text file content into a dropdown box
Hi Folks,
I have a text file filled with commands. and i would like to turn this text file into a dropdown ring box, how do i do that??
textfile attached.
Lee
Solved!
Go to Solution.
Attachments:
commands.txt 2 KBThat's not extracting anything from the lines. That's just dumping the contents of the file directly into the ring. That can be accomplished by simply doing this:
Message Edited by smercurio_fc on 06-03-2010 05:03 PM
Attachments:
fp.png 38 KB
dump into ring.vi 9 KB -
How to print a text file contents using java.
Using Input and Output streams I can add and retrive the contents to/from text file. But how to send this file contents to the printer or how to print the file.
Example from my code:
private void printErrorReport()
PrintJob pjob = getToolkit().getPrintJob(m_frame,null,null);
if (pjob != null) {
Graphics pg = pjob.getGraphics();
if (pg != null) {
String s = detailsArea.getText();
printLongString (pjob, pg, s);
pg.dispose();
pjob.end();
// Utility method needed
void printLongString (PrintJob pjob, Graphics pg, String s) {
int pageNum = 1;
int linesForThisPage = 0;
int linesForThisJob = 0;
// Note: String is immutable so won't change while printing.
if (!(pg instanceof PrintGraphics)) {
throw new IllegalArgumentException ("Graphics context not PrintGraphics");
StringReader sr = new StringReader (s);
LineNumberReader lnr = new LineNumberReader (sr);
String nextLine = " ";
int pageHeight = pjob.getPageDimension().height;
pageHeight -= 20;
Font helv = new Font("Arial", Font.PLAIN, 12);
//have to set the font to get any output
pg.setFont (helv);
FontMetrics fm = pg.getFontMetrics(helv);
int fontHeight = fm.getHeight();
int fontDescent = fm.getDescent();
int curHeight = 0;
try {
do {
nextLine = lnr.readLine();
if (nextLine != null) {
if ((curHeight + fontHeight) > pageHeight) {
// New Page
System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
pageNum++;
linesForThisPage = 0;
pg.dispose();
pg = pjob.getGraphics();
if (pg != null) {
pg.setFont (helv);
curHeight = 0;
curHeight += fontHeight;
if (pg != null) {
pg.drawString (nextLine, 0, curHeight - fontDescent);
linesForThisPage++;
linesForThisJob++;
} else {
System.out.println ("pg null");
} while (nextLine != null);
} catch (EOFException eof) {
// Fine, ignore
} catch (Throwable t) { // Anything else
t.printStackTrace();
System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
System.out.println ("pages printed: " + pageNum);
System.out.println ("total lines printed: " + linesForThisJob);
} -
Send text file content as the body of an email using Send-MailMessage
I am taking the last 8 lines of a bunch of robocopy logs and bunching them together.
Get-ChildItem -Filter *.log | ForEach {
$a += Get-Content $_.Name | Select -Last 8
$a += Write-output ' '`r
$a += Write-Output '------------------------------------------------------------------------------'`r
I then wanted to use this as the body of an email (send-mailmessage). It all works but the formatting is lost in the email. I've tried using Out-String and ConvertTo-HTML with little luck.
If I look at $a in the above it looks fine in the PowerShell console it's just lost when it reaches my inbox.
I am using v2 of PowerShell and sadly can't upgrade it.The issue isn't that part. It's the content of the log files that loses its formatting.
$a += Get-Content $_.Name | Select -Last 8 -
How to get the content of text file to write in JTextArea?
Hello,
I have text area and File chooser..
i wanna the content of choosed file to be written into text area..
I have this code:
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
public class Test_Stemmer extends JFrame {
public Test_Stemmer() {
super("Arabic Stemmer..");
setSize(350, 470);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JButton openButton = new JButton("Open");
JButton saveButton = new JButton("Save");
JButton dirButton = new JButton("Pick Dir");
JTextArea ta=new JTextArea("File will be written here", 10, 25);
JTextArea ta2=new JTextArea("Stemmed File will be written here", 10, 25);
final JLabel statusbar =
new JLabel("Output of your selection will go here");
// Create a file chooser that opens up as an Open dialog
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
int option = chooser.showOpenDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
File[] sf = chooser.getSelectedFiles();
String filelist = "nothing";
if (sf.length > 0) filelist = sf[0].getName();
for (int i = 1; i < sf.length; i++) {
filelist += ", " + sf.getName();
statusbar.setText("You chose " + filelist);
else {
statusbar.setText("You canceled.");
// Create a file chooser that opens up as a Save dialog
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
int option = chooser.showSaveDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
statusbar.setText("You saved " + ((chooser.getSelectedFile()!=null)?
chooser.getSelectedFile().getName():"nothing"));
else {
statusbar.setText("You canceled.");
// Create a file chooser that allows you to pick a directory
// rather than a file
dirButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int option = chooser.showOpenDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
statusbar.setText("You opened " + ((chooser.getSelectedFile()!=null)?
chooser.getSelectedFile().getName():"nothing"));
else {
statusbar.setText("You canceled.");
c.add(openButton);
c.add(saveButton);
c.add(dirButton);
c.add(statusbar);
c.add(ta);
c.add(ta2);
public static void main(String args[]) {
Test_Stemmer sfc = new Test_Stemmer();
sfc.setVisible(true);
}could you please help me, and tell me what to add or to modify,,
Thank you..realahmed8 wrote:
thanks masijade,
i have filter the file chooser for only text files,
but i still don't know how to use FileReader to put text file content to the text area (ta) ..
please tell me how and where to use it..How? -- See the IO Tutorials on Sun for the FileReader (and I assume you know how to call setText and append in the JTextArea).
Where? -- In the actionPerformed method (better would be a separate thread that is triggered through the actionPerformed method, but that is probably beyond you at the moment), of course.
Give it a try. -
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.... -
I have a text file of an English-French dictionary.
I want to enter an english phrase into a text box
- search through the list(dictionary)
- and output the French phrase in a separate text box.
I want to search through the dictionary(list) for an english
phrase e.g. "accost" and output the corresponding french phrase
"accoster" to a text box.
Here is the format that the dictionary is in
English first followed by french followed by word type
accordions accorde/ons[Noun]
accords accords[Noun]
accost accoster[Verb]
account compte[Noun]
Is it possible to add a text files contents into a list?
Imagine manually typing all the contents.
Thanks,
JackPlease see the replies to this cross-post at
http://director-online.com/forums/read.php?2,27554 -
How can i read all the lines from a text file in specific places and use the data ?
string[] lines = File.ReadAllLines(@"c:\wmiclasses\wmiclasses1.txt");
for (int i = 0; i < lines.Length; i++)
if (lines[i].StartsWith("ComboBox"))
And this is how the text file content look like:
ComboBox Name cmbxOption
Classes Win32_1394Controller
Classes Win32_1394ControllerDevice
ComboBox Name cmbxStorage
Classes Win32_LogicalFileSecuritySetting
Classes Win32_TapeDrive
What i need to do is some things:
1. Each time the line start with ComboBox then to get only the ComboBox name from the line for example cmbxOption.
Since i have already this ComboBoxes in my form1 designer i need to identify where the cmbxOption start and end and when the next ComboBox start cmbxStorage.
2. To get all the lines of the current ComboBox for example this lines belong to cmbxOption:
Classes Win32_1394Controller
Classes Win32_1394ControllerDevice
3. To create from each line a Key and Value for example from the line:
Classes Win32_1394Controller
Then the key will be Win32_1394Controller and the value will be only 1394Controller
Then the second line key Win32_1394ControllerDevice and value only 1394ControllerDevice
4. To add to the correct belonging ComboBox only the value 1394Controller.
5. To make that when i select in the ComboBox for example in cmbxOption the item 1394Controller it will act like i selected Win32_1394Controller.
For example in this event:
private void cmbxOption_SelectedIndexChanged(object sender, EventArgs e)
InsertInfo(cmbxOption.SelectedItem.ToString(), ref lstDisplayHardware, chkHardware.Checked);
In need that the SelectedItem will be Win32_1394Controller but the user will see in the cmbxOption only 1394Controller without the Win32_
This is the start of the method InsertInfo
private void InsertInfo(string Key, ref ListView lst, bool DontInsertNull)
That's why i need that the Key will be Win32_1394Controller but i want that the user will see in the ComboBox only 1394Controller without the Win32_Hello,
Here is a running start on getting specific lines in the case lines starting with ComboBox. I took your data and placed it into a text file named TextFile1.txt in the bin\debug folder. Code below was done in
a console app.
using System;
using System.IO;
using System.Linq;
namespace ConsoleApplication1
internal class Program
private static void Main(string[] args)
var result =
from T in File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TextFile1.txt"))
.Select((line, index) => new { Line = line, Index = index })
.Where((s) => s.Line.StartsWith("ComboBox"))
select T
).ToList();
if (result.Count > 0)
foreach (var item in result)
Console.WriteLine("Line: {0} Data: {1}", item.Index, item.Line);
Console.ReadLine();
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions. -
Importing text file (with file names) into Automator.. is it possible?
Hello all,
I have been working with Windows Batch files for my line of work. I have a couple of file names in a text file (a column), which I want to copy from one folder of one hdd to another folder on a different hdd. I have been trying to do this kind of work with a Mac. I already know how you copy and rename files in automator (which isn't difficult, of course) but you have to 'select' the files in the finder first (with get specified items).
But the only way i see that you can specify items is by selecting them... is there a way to import a text file with all the file names instead of selecting all the file names manually?
or is there an AppleScript alternative which I can use to import the text file (or just copy into applescript) and run before the query's of copying and renaming the files? I am kind of new to Apple programming.
The text file looks like this:
image1.jpg
image2.jpg
etc..
so there has to be a command to: 'goto' a specific folder as well.
Thanks in advance!You can import text files, but if they are just names you will need an additional action to add the source folder path. A *Run AppleScript* action can be used, for example:
Tested workflow:
1) *Ask for Finder Items* {Type: files } -- choose the text file containing the names
2) *Combine Text Files* -- this gets the text file contents
3) *Filter Paragraphs* { return paragraphs that are not empty } -- skip blank lines
4) *Run AppleScript* -- copy and paste the following script:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 680; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters} -- add folder path
add the specified folder path to a list of file names
input: a list of text items (the file names)
output: a list of file paths (aliases)
set output to {}
set SkippedItems to {} -- this will be a list of skipped items (errors)
set SourceFolder to (choose folder with prompt "Choose the folder containing the file names") as text -- this is the folder containing the names
repeat with AnItem in the input -- step through each name in the input
try
set AnItem to SourceFolder & AnItem -- add the prefix
set the end of the output to (AnItem as alias) -- test
on error number ErrorNumber -- oops
set ErrorNumber to (" (" & ErrorNumber as text) & ")" -- add the specific error number
set the end of SkippedItems to (AnItem as text) & ErrorNumber
end try
end repeat
ShowSkippedAlert for SkippedItems
return the output -- pass the result(s) to the next action
end run
to ShowSkippedAlert for SkippedItems
show an alert dialog for any items skipped, with the option to cancel the workflow
parameters - SkippedItems [list]: the items skipped
returns nothing
if SkippedItems is not {} then
set {AlertText, TheCount} to {"Error with AppleScript action", count SkippedItems}
if TheCount is greater than 1 then
set theMessage to (TheCount as text) & space & " items were skipped:"
else
set theMessage to "1 " & " item was skipped:"
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SkippedItems, AppleScript's text item delimiters} to {SkippedItems as text, TempTID}
if button returned of (display alert AlertText message (theMessage & return & SkippedItems) ¬
alternate button "Cancel" default button "OK") is "Cancel" then error number -128
end if
return
end ShowSkippedAlert
</pre>
5) *Copy Finder Items* { To: _your external drive_ } -
How to make an applet to read the Text file present inside a jar
Hi All,
I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
The applet code runs successfully when i run the applet in command prompt like
{color:#ff0000}*java ReadFile*{color}
And i am getting the needed results.
Then i made a jar file with the applet code and text file as
{color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
Then i have inlcuded this applet inside a html file as
{color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
Applet is not recognizing trhe text file present inside the jar file.
Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.what code in your applet gets the text file and reads it? are you using getResource or something similar?
-
How to view the file content from the directory? getting Error:ORA-21560
SQL> create directory READ_LOB_DIR as 'D:\Prj\Comm\Data';
CREATE OR REPLACE Procedure READ_FILE_LOB IS
-- Input Directory as specified in create directory
l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
-- Input File which is read word by word
l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
-- Separator Character between words is a BLANK (ascii = 32)
l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
-- Character at the end of the file is NEWLINE (ascii = 10)
l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
-- Pointer to the BFILE
l_loc BFILE;
-- Current position in the file (file begins at position 1)
l_pos NUMBER := 1;
-- Amount of characters have been read
l_sum BINARY_INTEGER := 0;
-- Read Buffer
l_buf VARCHAR2(500);
-- End of the current word which will be read
l_end NUMBER;
-- Return value
l_ret BOOLEAN := FALSE;
BEGIN
-- Mapping the physical file with the pointer to the BFILE
l_loc := BFILENAME(l_dir, l_fil);
-- Check if the file exists
l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
IF (l_ret) THEN
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' exists');
-- Open the file in READ_ONLY mode
DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
LOOP
-- Calculate the end of the current word
l_end := DBMS_LOB.INSTR(l_loc, l_seb, l_pos, 1);
-- Process end-of-file
IF (l_end = 0) THEN
l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
l_sum := l_end - l_pos - 1;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
EXIT;
END IF;
-- Read until end-of-file
l_sum := l_end - l_pos;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
l_pos := l_pos + l_sum + 1;
END LOOP;
DBMS_LOB.CLOSE(l_loc);
ELSE
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' does not exist');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error:' || SQLERRM);
DBMS_LOB.CLOSE(l_loc);
END;
The Text file content is...
Copyright 1996,2001 Oracle Corporation. All Rights Reserved
This file contains installation instructions for installing the
Oracle8 ODBC Driver software.
It is divided into four parts:
o Part I: Summary of systems supported by Oracle8 ODBC client
software
Lists the platforms on which the Oracle8 ODBC Client software can
be installed.
o Part II: Oracle8 ODBC Driver software.
Describes the files, and installation prerequisites for the Oracle8
ODBC driver software.
o Part III: Exploding the kit onto your system
Describes how to explode the kit onto your system hard drive.
o Part IV: Installation Instructions
Describes how to install the Oracle8 ODBC driver.
Part I: Systems supported by the Oracle8 client software
You can install the ODBC client software on any of the following systems:
o Windows 2000
o Windows NT X86
o Windows 95
o Windows 98
The Oracle8 ODBC Driver provides support for ODBC connections
from Windows 2000, Windows NT, Windows 95, and Windows 98 systems
to Oracle databases.
o Part II: Oracle8 ODBC Driver software.
Refer to the following files for information about the Oracle8 ODBC Driver:
LICENSE.TXT - Oracle8 ODBC Driver License Agreement. Read carefully
before installing and/or using this product. Enclosed in
your software distribution kit.
SQORA.HLP - A Window's Help file which is the primary reference
manual for the Oracle8 ODBC Driver.
ODBCRelnotes.WRI - The release notes for the Oracle8 ODBC Driver
which contains information which may have not been
included in the Help file.
Installation Prerequisites
See the Oracle8 ODBC Driver release notes (ODBCRelnotes.WRI),
for a complete list of software products required and their versions.
Time Required
The installation of the Oracle8 ODBC Driver takes approximately 5
minutes. The actual time may be shorter or longer, depending upon
your hardware configuration.
Disk Space Required
The Oracle8 ODBC driver installation requires approximately 2
megabytes of available storage space. The space required depends upon
what files you already have installed. The installation procedure
checks to see if you have enough available disk space. If you do not,
the installation fails.
Part III: Exploding the Kit onto your system
Expand the self-extracting archive file onto your hard drive.
C:\> ORA8174.EXE
Part IV: Installation Instructions
Oracle8 ODBC Driver 8.1.7.4.0
This section assumes the following:
1. MS Windows 2000, Windows NT, Windows 95 or Windows 98 is running.
2. Oracle Universal Installer shipping with 8.1.7 has already been
installed on your system.
3. Part III has been completed.
Software fixes:
Refer to release notes (ODBCRelnotes.wri) for a complete list of
Software fixes.
Installation Instructions
Once the self-extracting archive file ORA8174.EXE has been
exploded it will create an installable directory structure
onto your hard drive. Run the Oracle Universal Installer from
your local drive.
1. On the screen "File Locations" use the "Browse" button of
the source path to choose the file 'products.jar' from the
folder that ORA8174.EXE was extracted to. Choose 'Next'.
2. You will receive a warning that some of the dependencies of
this product are not found in the staging area. This warning
is OK. The ODBC driver depends on the Net8 Client being already
installed on the system. Answer 'Yes' to continue.
Oracle is a registered trademark of Oracle Corporation.
Microsoft, MS are registered trademarks of Microsoft Corporation.
Microsoft Windows, Windows NT, Windows 95, Windows 98 and Open Database
Connectivity are trademarks of Microsoft Corporation.
All other trademarks and registered trademarks are the property
of their respective owners.
The output was...
File testfile.txt in Directory READ_LOB_DIR exists
Copyright
1996,2001
Oracle
Corporation.
All
Rights
Reserved
This
file
contains
installation
instructions
for
installing
the
Oracle8
ODBC
Driver
software.
It
is
divided
into
four
parts:
o
Part
I:
Summary
of
systems
supported
by
Oracle8
ODBC
client
Error:ORA-21560: argument 2 is null, invalid, or out of range
I want to diplay/view as per file content format from the file under that specified directory.
Have any other method / any help or suggestions would be really appreciated.I changed the code like...
CREATE OR REPLACE Procedure READ_FILE_LOB_tmp IS
-- Input Directory as specified in create directory
l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
-- Input File which is read word by word
l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
-- Separator Character between words is a BLANK (ascii = 32)
l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
-- Character at the end of the file is NEWLINE (ascii = 10)
l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
-- Pointer to the BFILE
l_loc BFILE;
-- Current position in the file (file begins at position 1)
l_pos NUMBER := 1;
-- Amount of characters have been read
l_sum BINARY_INTEGER := 0;
-- Read Buffer
l_buf VARCHAR2(4000);
-- End of the current word which will be read
l_end NUMBER;
-- Return value
l_ret BOOLEAN := FALSE;
BEGIN
-- Mapping the physical file with the pointer to the BFILE
l_loc := BFILENAME(l_dir, l_fil);
-- Check if the file exists
l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
IF (l_ret) THEN
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' exists');
-- Open the file in READ_ONLY mode
DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
LOOP
-- Calculate the end of the current word
l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
-- Process end-of-file
IF (l_end = 0) THEN
EXIT;
END IF;
-- Read until end-of-file
l_sum := l_end - l_pos;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
l_pos := l_pos + l_sum + 1;
END LOOP;
DBMS_LOB.CLOSE(l_loc);
ELSE
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' does not exist');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error:' || SQLERRM);
DBMS_LOB.CLOSE(l_loc);
END;
Now its working fine with one addtional line...
The file content is...
This is My Content
This is My Content
This is My Content
This is My Content
This is My Content
But The output was...
File testfile.txt in Directory READ_LOB_DIR exists
This is My Content
This is My Content
This is My Content
This is My Content
This is My Content
here, i want to delete that additonal line...?
Maybe you are looking for
-
Hi, Iam Currentl running File to Idoc interface. Message is success in moni also and runtime workbecnh also. But when iam checking R/3 using WE19 tcode by giving date its not showing . It showing like no values found. Can anybody tel me what is the r
-
How do I combine 2 media folders
I'm looking for a way to combine 2 media folders, from 2 separate computers, to one new computer. 2 systems were used to work with one iPod, so I have 2 media folders that I need to combine. Is there a way to get this done in iTunes? I prefer not
-
Requirement of E-sourcing and e-CLM (contract life cycle management) in SRM
Dear Experts, Does one need to install e-sourcing and eCLM (contract life cycle management) in SRM 7.0 to take the benefit of full functionality available in SRM 7.0? My understanding says that e-Sourcing and CLM are not must for SRM 7.0. They are ba
-
How do I cancel a printing job half way through?
How do I cancel a printing job half way through? hp psc 1310 series This question was solved. View Solution.
-
OS 10.5.8 to OS 10.6.3 problems
I have an Imac which I just updated from OS 10.5.8 to OS 10.6.3 (snow leopard). I could not start up my photoshop CS unless I installed rosseta from the new OS disk. Once I did this photoshop was glitchy and I could not scan from my canon MP470 p