Loading a text file to a buffer
Hi,
I have a very simple question,
I have a text file which I want to read and load it in a string buffer, but I don't want to user BufferedReader and append line by line,
is it possible to load the text file into StringBuffer without any loops / appends?
Thanks,
S.
File file = new File("fileName.fileExtension");
byte[] c = new char[file.length()];
FileReader reader = new FileReader(file);
try{
reader.read(c);
}catch(IOException e) { System.out.println("An error has ocurred");}
String makeMeString = new String(c);
Stringbuffer buff = new StringBuffer(makeMeString);
Similar Messages
-
"how to load a text file to oracle table"
hi to all
can anybody help me "how to load a text file to oracle table", this is first time i am doing, plz give me steps.
Regards
MKhaleelUsage: SQLLOAD keyword=value [,keyword=value,...]
Valid Keywords:
userid -- ORACLE username/password
control -- Control file name
log -- Log file name
bad -- Bad file name
data -- Data file name
discard -- Discard file name
discardmax -- Number of discards to allow (Default all)
skip -- Number of logical records to skip (Default 0)
load -- Number of logical records to load (Default all)
errors -- Number of errors to allow (Default 50)
rows -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional path 64, Direct path all)
bindsize -- Size of conventional path bind array in bytes (Default 256000)
silent -- Suppress messages during run (header, feedback, errors, discards, partitions)
direct -- use direct path (Default FALSE)
parfile -- parameter file: name of file that contains parameter specifications
parallel -- do parallel load (Default FALSE)
file -- File to allocate extents from
skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
readsize -- Size of Read buffer (Default 1048576)
external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE
(Default NOT_USED)
columnarrayrows -- Number of rows for direct path column array (Default 5000)
streamsize -- Size of direct path stream buffer in bytes (Default 256000)
multithreading -- use multithreading in direct path
resumable -- enable or disable resumable for current session (Default FALSE)
resumable_name -- text string to help identify resumable statement
resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
PLEASE NOTE: Command-line parameters may be specified either by position or by keywords. An example of the former case is 'sqlldr scott/tiger foo'; an example of the latter is 'sqlldr control=foo userid=scott/tiger'. One may specify parameters by position before but not after parameters specified by keywords. For example, 'sqlldr scott/tiger control=foo logfile=log' is allowed, but 'sqlldr scott/tiger control=foo log' is not, even though the position of the parameter 'log' is correct.
SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\PFS2004.CTL LOG=D:\PFS2004.LOG BAD=D:\PFS2004.BAD DATA=D:\PFS2004.CSV
SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\CLAB2004.CTL LOG=D:\CLAB2004.LOG BAD=D:\CLAB2004.BAD DATA=D:\CLAB2004.CSV
SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CTL LOG=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.LOG BAD=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.BAD DATA=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CSV -
How can I use sql loader to load a text file into a table
Hi, I need to load a text file that has records on lines tab delimited into a table. How would I be able to use the sql loader to do this? I am using korn shell to do this. I am very new at this...so any kind of helpful examples or documentation would be very appreciated. I would love to see some examples to help me understand if possible. I need help! Thanks alot!
You should check out the documentation on SQL*Loader in the online Oracle document titled Utilities. Here's a link to the 9iR2 version of it: http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96652/part2.htm#436160
Hope this helps. -
How to load a text file?
I'm trying to load a text file and I've run into a wall. So
far, I've loaded swf files, image files and XML files without
problems. But the text files just don't seem to load.
It's not a tough situation. The files are in the same
directory as the application. When I run it, I see no sign that the
file has loaded, but haven't found the error trapping to tell me
what is (not) going on.
The code below was culled from examples on the web, they seem
fairly consistent, and they are copied pretty much exactly. and I
put them both into a single action to test them.
Any clues as to what is not happening? I need to read an old
txt data file that was used with AS2, with pairs of names and
variables. The first example just reads a couple of variables. The
second just reads some random text. I'm just trying to see what
works here, so I can incorporate working code into the real
program.
Thanks for your help.Thanks Joergen,
I put in the changes you suggested and still no sign that the
files are even being opened., but it's very good to have the
feedback. Just the fact that someone is getting them to run gives
me confidence in the basic code. I'll hack on it more and let you
know what the answer turns out to be for me.
Thanks. -
How to load a text file int JEditorPane and highlight some words (Urgent !)
I want to load a text file into a JEditorPane and then highlights some keywords such as while,if and else.I am using an EditorKit in order to style the JEditorPane. I have no difficulty while giving the input through the keyboard but lots of exceptions are thrown if i try to load the string from a file.
Hi,
I think the setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace) will solve the problem.
You can create your own Styled Document and set it to the Editor Pane. -
Loading a text file on startup into a hashtable
I am trying to load to seperate textfiles into the same hashtable.
The textfiles are something like an employee and employee number everything goes in at the same time. How do i load these text files into the hashtable. Also any good tutorials or code samples on hashtables would be greatly appreciated.
Thanks In AdvanceYou read the text files, one line at a time, and break up each line in whatever way you need to. Then you choose the bits to put in the hashtable (key and value) for each line and put those bits into the hashtable.
http://java.sun.com/docs/books/tutorial/essential/index.html
http://java.sun.com/docs/books/tutorial/collections/index.html -
Loading a text file from a relative location in shockwave
Hi all
I'm REALLY sorry I have to post about such an inane problem.
I've googled this and looked in forums and found several
suggestions but none of them are working for me. I want to load a
text file from the same directory as my movie. I can get this
working in authoring mode, in a projector, and in a shockwave movie
on the local machine (using getNetText("/text.txt")).
But when i put the shockwave movie on a server, it does NOT
work. The macromedia documentation says that getNetText works with
relative URLs. But when I put in the full URL, it does work, so
obviously the shockwave movie is having a problem finding the text
file which IS in the same directory as it.
Any suggestions / ideas? All i want to do is access a text
file :)
Sorry again for such a lame problem
Mikethanks - this worked. I also had to not use a repeat loop to
wait for netDone() to return true.
Thanks again
MIke -
Error loading a text file during creation of data load rule
Hi,
I am trying to load this text file but whenever I open File -> Open Data File and then click on the file, it says "Invalid Blank Character in name". I tried changing the name of the file and everything but I do not understand what it really means. Can anyone help me out please? This seems like a simple error but I am unable to figure it out. Thanks.
-- AdiAs Glenn said, there should not be any space in the path that causes the error.For instance if you have ur file in the desktop(C:\Documents and Settings\Desktop), there would be space in between Documents and Settings. To avoid this, you could directly save in your local disk drive(C:\, D:, E:\).
Regards
Cnee -
Loading a text file in a gzip or zip archive using an applet to a String
How do I load a text file in a gzip or zip archive using an applet to a String, not a byte array? Give me both gzip and zip examples.
This doesn't work:
try
java.net.URL url = new java.net.URL(getCodeBase() + filename);
inputStream = new java.io.BufferedInputStream(url.openStream());
if (filename.toLowerCase().endsWith(".txt.gz"))
inputStream = (java.io.InputStream)(new java.util.zip.GZIPInputStream(inputStream));
else if (filename.toLowerCase().endsWith(".zip"))
java.util.zip.ZipInputStream zipInputStream = new java.util.zip.ZipInputStream(inputStream);
java.util.zip.ZipEntry zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null && (zipEntry.isDirectory() || !zipEntry.getName().toLowerCase().endsWith(".txt")))
zipEntry = zipInputStream.getNextEntry();
if (zipEntry == null)
zipInputStream.close();
inputStream.close();
return "";
inputStream = zipInputStream;
else
byte bytes[] = new byte[10000000];
byte s;
int i = 0;
while (((s = inputStream.read())) != null)
bytes[i++] = s;
inputStream.close();
catch (Exception e)
} -
Loading a text file into a global variable issue - really a global var?
From all the documentation and examples I can find, it appears that it would be
correct to create a global array variable [outside of any functions] to load image names into,
then use these images for a slideshow. I want to make the app dynamic, in that changing the text file gives a new set of images.
The global variable goes null [no values] after the load event listener. Why is that?
Isn't global, well global, and alive for the duration of the SWF?
PARAMS.TXT:
monthNames=January,February,March,April,May,June,July,August,September,October,November,De cember&dayNames=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
CODE:
var dNames:Array = new Array();
var mNames:Array = new Array();
var request:URLRequest = new URLRequest("images/params.txt");
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
variables.load(request);
catch (error:Error)
trace("Unable to load URL: " + error);
trace("2 mNames 2: " + mNames[2]);
trace("2 dNames 3: " + dNames[3]);
stop();
function completeHandler(event:Event):void
var loader:URLLoader = URLLoader(event.target);
dNames = loader.data.dayNames.split(",");
mNames = loader.data.monthNames.split(",");
trace(loader.data.dayNames);
trace("1 mNames 2: " + mNames[2]);
trace("1 dNames 3: " + dNames[3]);
OUTPUT:
2 mNames 2: undefined
2 dNames 3: undefined
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
1 mNames 2: March
1 dNames 3: Wednesday
How do I access these values after loading from the external file, after the load?
Thanks in advance.The statement you quoted from whatever Adobe documentation is correct.
If you want to load the data into the arrays before anything else happens, then have anything else that happens execute via the completeHandler function... after the data is loaded and processed into the arrays.
the command: loadFile() executes before the trace("2:" +images[4]); command. The loadFile function is processed and the loading process BEGINS... but starting the loading does not delay the main processing from continuing down the line--the loading itself becomes a secondary/background task. The command was to execute the loadFile function and the processing of that function was completed. If you don't believe so, then add a trace...
function loadFile():void
vars.dataFormat = URLLoaderDataFormat.VARIABLES;
vars.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
vars.load(new URLRequest("images/fnames.txt"));
trace("started loading");
If you add that trace, you should see that the loadFile function execution is completed and the next line in your code is then processed... trace(2....)
The addEventlistener does not stop anything. The addEventListener code is assigning a monitor, not a traffic controller... it is telling the monitor to indicate when the data has finished loading. It is not telling anything to stop program execution.
So if you want to wait until the data is loaded before you do anything else... it goes....
function onComplete(evt:Event):void
var urlVars:URLVariables = evt.target.data;
images = vars.data.images.split(",");
tnails = vars.data.thumbnails.split(",");
................HERE................. -
How to load a text file (ASCII) into a TS string variable?
I need to load a ASCII file into a TS string variable for subsequent processing. I tried the SecuenceBuilder DLL (in the examples directory) but it seems that this DLL has a bug. Some text files are not loaded properly. I have also tried the kernel32 functions (openfile, createfile, readfile ... ) handling them as a C program, but with no success. The property loader feature of TS is not the suitable solution for me, because I would have to modify all my text files to include some specific fields (step name, variables, starmarker ...). Doy you know an alternative procedure to load text files or any DLL that implements what I look for ? Any help would be grateful. Cesar ([email protected])
Hi Cesar,
I don't know if you have found a solution, but attached is a DLL built in VC that will read the text out of a file into a TestStand variable. The attached sequence file \SequenceFile1.seq contains a step type that is set to call the DLL responsible for reading the file. It reads the file specified under Step.FilePath and stores the data in Step.ReadData. Please let me know if this works for you. I have attached the source as well.
Regards,
Bob
Attachments:
ReadFile.zip 3628 KB -
Turning off caching for loading a text file
I'm new to AS3 and don't understand the properties setting
for URLRequest. I'm trying to turn caching off so when I reload the
text file, it always gets a fresh copy. I keep getting compiler
errors however with the useCache line. I'm not accessing the
properties correctly or something. When I take out that line it
works fine but always fetches the cached file.
My code is:
loadDoctorVariables();
function loadDoctorVariables() {
var requestJo:URLRequest = new URLRequest("
http://www.grxsolutions.com/gtslideshow3/"+doctorURL+".txt");
//requestJo.useCache(false);
requestJo.useCache = false;
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
variables.load(requestJo);
catch (error:Error)
trace("Unable to load URL: " + error);
function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace(loader.data.dayNames);
trace(loader.data.monthNames);
trace(loader.data);
trace(loader.data.saturationColor);
//saturationColor=10&hue=100&tint=255&bright=12&bgimage=ironman&slidesused=1,2,3,4,7,8,9, 10,11&voice=male1&alternateslides=7,doctorbob1,11,doctorbob2
}append a random string to the URL, ie
var requestJo:URLRequest = new URLRequest("
http://www.grxsolutions.com/gtslideshow3"+doctorURL+".txt"+"?c="+Math.random()); -
Loading a text file into Terminal App
Hi,
I am trying to load a textfile into my Terminal App using the Import utility under the Shell drop down menu.
But when I try choosing the text files after clicking Import, I am unable to select a text file because they are
all greyed out. Only folders seems to be selectable.
Please help.I have no idea what you are trying to do. What does "load a textfile" mean?
The Import… command is for importing a Terminal settings file (exported using the Export Settings… command on another computer or user). -
Hi! I've got several archived text files - 040107.txt,
040207.txt, 040307.txt, for example - and I want to be able to
build a dynamic link which loads whichever file is selected into
the Flash movie. This list needs to be able to build itself as I
write new files every day and add the old ones to the archive. I'm
stumped. How can I do this?If you are using XML to load data, then use the CDATA to wrap
the html text.
If you are using LoadVars to load data, be sure you do not
have any & in the text content. If you do convert to hex.
Bottom line is you need to trace the text you load to see
what you are getting.
Flash should show HTML if you have the
TextField.htmll
property set to true which is also done in IDE with "Render Text as
HTML". But you must use the
TextField.htmlText
property to set the text.
Finally malformed HTML in Flash TextFields generally dies
like you describe.
You should be able to test the display of data in dynamic
TextFields with a simple Flash movie containing the TextField and
the text stored in a variable and then loaded into the htmlText
property. If it is not working there then you have to look at the
data. -
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
-
Report generation in HTML, PDF over Word
Hi, I am building a report by generating it in Word, PDF formats. To generate the report with data in a certain format i am using MS Word API to get a better layouts for the content, fonts, alignments, etc. I am able to bring the application with for
-
Before last night, when I typed far I'd get as the top of my list fark.com. Now, instead, it tries to search for Farmers Insurance, Farmville, and Farrah Abraham-- how do I turn that off?
-
I installed 2.0.2 on my 3G and everything seemed fine. Nothing to write home about, but the keyboard seemed faster. After a couple days, however, issues have started to surface: 1. Dropped calls (ironically to Apple Support) 2. Safari doesn't reorien
-
Continues integration with OS X Server and Xcode Bot
I want to to do the continues integration using Xcode bots. I have installed OSX Mavericks and Server(version 3). Iam able to create bots using Xcode 5.0.1. While integrating it is successfully performing analysing testing but always the final integr
-
I've entered a lot of enteries into my Apple Notes app and upon opening my Notes for the 1st time in 2015 all notes entered are gone I haven't updated anything I'm using a iMac OS 10.10.1 where are my notes ? I've been using Mac's since 1990 usu