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)
}
Similar Messages
-
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 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); -
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 -
"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 -
The program doest enterpret my figures from the text file in the correct way since the numbers contain dots instead of commas. Is there a way to fix this in labVIEW, or do I have to change the files before reading them in the program? Thanks beforehend!
You must go in the labview option menu, you can select 'use the local
separator' in the front side submenu (LV6i).
If you use the "From Exponential/Fract/Eng" vi, you are able to select this
opton (with a boolean) without changing the labview parameters.
(sorry for my english)
Lange Jerome
FRANCE
"Nina" a ecrit dans le message news:
[email protected]..
> I would like to read a text file in which the decimal numbers are
> using dots instead of commas. Is there a way of converting this in
> labVIEW, or how can I get the program to enterpret the figures in the
> correct way?
>
> The program doest enterpret my figures from the text file in the
> correct way since the numbers contain dots instea
d of commas. Is there
> a way to fix this in labVIEW, or do I have to change the files before
> reading them in the program? Thanks beforehend! -
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.
Maybe you are looking for
-
Reinstall IIS on a SBS 2011?
I deleted IIS 7 and WSUS on a SBS 2011 server. Now IIS wont reinstall. Reason: Exchange Console did not find the local Server any more and Exchange cannot be administered. Maybe the reason was the Exchange SP3 installation in Sept 2013. Nobody did no
-
PR creation using BAPI_REQUISITION_CREATE, Service lines query
Hi, I am trying to create the PR for service agreements and i'm able to create the same. My first query is how to populate the data in LIMIT tab(Overall Limit & Expected value) for each line item of PR. I am using BAPI_REQUISITION_CREATE but its not
-
Accessing stage objects from other objects
I have drawn colored rods which I have placed in the library and have put one of each on the stage with instance names like blueRod_mc, etc. I place them around with time-line code like blueRod_mc.x = 300.0; I have now created an Actionscript class c
-
Hello, I work with VB6 and ADO in Sql-Server database, I would like work with Oracle databases but in my table in Sql-Server I have a primary key field that is a automatic counter (identity). Is possible in Oracle has a primary key field that is a co
-
Is there a way to get Itunes on my new computer to retrieve purchased songs
Is there a way to get Itunes on my new computer to retrieve purchased songs without connecting to my old computer or using disks?