Reading contents of tar.gz file programatically
Hi,
I have a file explorer type application, where I want the user to be able to double click on the tar.gz file and see the contents of the tar archive inside the .gz file.
Of course, we dont want to have to extract the entire .gz file first. But it seems that the only way to read a .gz file is to use GZIPInputStream and if we through that, we will end up extracting the entire file.
So can anyone tell me how to go about doing this?
Hi,
yes you're right. It's quite tricky sometimes to get what you need from a GZip file.
What I found out today worked greatly.
First of all, you need to get Apache Ant and inside the ant.jar file you'll locate the TAR package under tools (org.apache.tools.tar)
So:
1) Create a GZIPInputStream from the file (java.util.zip.GZIPInputStream)
2) read the file entirely, coping it using a FileOutputStream
3) In point 2, you created a tar file, you can read it with TarInputStream in org.apache.tools.tar TarInputStream.
4) Get the entry you look for with TarEntry using
- TarInputStream ts = new TarInputStream(file);
- while (true){
TarEntry t = ts.getNextEntry();
if (tgetName().equals("myEntry")){
//use ts to read this entry
ts.read (buffer, 0, buffer.length)
5) You have the unpacked Gzip entry where you want. Enjoy!
ZazzaZ
Similar Messages
-
If I use an app to remove duplicate pix does the app read content or only the file name such as IMG
If I use an app to remove duplicate pix does the app read content or only the file name such as IMG. I have some 2500 pix and the thought of trawling thru them toremove duplicates is mind numbing.
If the apps read the content then I am ok about that but if they only read the file name ... they maybe deleting stuff that isnt really a duplicateYou have to contact with the developer of the application. We do not know which app you are referring to and we do not know how that application works, but all apps of that type are supposed to delete duplicate files with the same format (like IMG, JPG...)
-
FTP to Read content of Text/xml file
Hi,
I need a help for reading content of text/xml file through FTP. Below I just am explaining the scenario.
Our application server is in UNIX. Now we have to run a report program to access in to a FTP server which is in windows platform. Using FTP_CONNECT, FTP_COMMAND, FTP_DISCONNECT we are able to connect to FTP server and also able to copy files from FTP server to SAP application server. After copied in application server, we are able to read the content of the txt file in to internal table in ABAP program using OPEN DATASET. But our requirement is that we want to read the text or xml file content into internal table while accessing into FTP server from SAP application instead of after copying the file into application server.
So please help me to solve my problem.
-PkThank you Bala,
But can you help me what should I pass against FNAME and CHARACTER_MODE Import parameter? Should I pass the full path of the file with name or only I have to pass file name ? For example if my text file name in FTP Server is test.txt and the IP of the ftp server is 10.10.2.3 then should I pass the value against FNAME as '
10.10.2.3\xyz\text.txt' ? Here xyz is the name of the directory in C drive where test.txt is exist.
Please help me.
-pk -
How to read contents of a property file sequentially
hello all,
please can any one tell me how to read contents of a property file sequentially.
i saw most of the classes provided by JAVA API, which get All keys and there return type is enumeration which dosent preserve , or may the getKeys() method of those classes do not preserve the sequential order.
Kindly do let me know if anyone has done this before.
Thanks.The best solution is that you redesign your program so that it does not depend on the order of the entries in the properties file.
If you really want to stay with your design, you will have to read the properties file yourself, line by line, just like you would read any other text file, and parse the content of each line yourself.
BufferedReader in = new BufferedReader(new FileReader("stuff.properties"));
String line;
while ((line = in.readLine()) != null) {
// Parse the line, use e.g. String.split() to split it around the '='
in.close(); -
Reading contents of uploaded excel file in web dynpro java
Hi All.
I am aware how to provide facility to upload files in web dynpro java. But my requirement is that on uploading a particular file (for eg. an excel file having 10 columns), I need to read the contents of that file and store it in a table in R/3.Can anyone suggest a way how I can read the contents of the uploaded file?
Thanks and Regards,
Saurabh.Hi.
I am having the following requirement : I have a FileUpload UI element where user clicks Browse button, selects a file from the local system and presses a Upload button. Upon pressing Upload, the name of the selected file and the contents of the file should be shown.
In the View context, I have two value attributes: FileName of type String and FileResource of type binary.
This is the code that I have in the Upload button action handler :
public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionUpload(ServerEvent)
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(
IPrivateReadExcelView.IContextElement.FILE_RESOURCE);
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.
getModifiableSimpleType();
IPrivateReadExcelView.IContextElement element = wdContext.createContextElement();
String fname = binaryType.getFileName();
wdComponentAPI.getMessageManager().reportSuccess("File selected - "+fname); //Statement 1
try {
wdComponentAPI.getMessageManager().reportSuccess("Successful"); // Statement 2
InputStream in = new FileInputStream(fname);
HSSFWorkbook wb = new HSSFWorkbook(in);
wdComponentAPI.getMessageManager().reportSuccess("Successful"); //Statement 3
int sheetsNo = wb.getNumberOfSheets();
for (int i=0;i<sheetsNo;i++) {
HSSFSheet sheet = wb.getSheetAt(i);
Iterator rowsNo = sheet.rowIterator();
while(rowsNo.hasNext()) {
HSSFRow rows = (HSSFRow)rowsNo.next();
Iterator colsNo = rows.cellIterator();
while(colsNo.hasNext()) {
HSSFCell cell = (HSSFCell)colsNo.next();
wdComponentAPI.getMessageManager().reportSuccess("File uploaded" +
"successfully");
if(cell.getCellType()==1) {
wdComponentAPI.getMessageManager().reportSuccess("00000"+
cell.getStringCellValue());
else if(cell.getCellType()==0) {
String str=""+cell.getNumericCellValue();
wdComponentAPI.getMessageManager().reportSuccess("11111"+str);
catch(Exception e) { wdComponentAPI.getMessageManager().raisePendingException();
//@@end
On pressing Upload button, name of selected file is being shown(Statement 1). I am also getting Statement 2 in the output. However I am not getting Statement 3 onwards.
Where am I going wrong? Can anyone shed some light on this? -
Reading CONTENT of a spool-file possible ?
hi there,
are there FM's or method of classes with which i can read the content of a spool-file ?
e.g. reading the content of a spool-file line by line to move it e.g. to a table ?
reg, MartinMartin,
You could try FM's CONVERT_ABAPSPOOLJOB_2_PDF or CONVERT_OTFSPOOLJOB_2_PDF.
Duane -
Read content in Microsoft Word file.
My new project is to read content in Microsoft Word. But,
blah blah blah code are appeared when I read microsoft word file
with cffile tag, and display included content in textarea. Here is
my coding. Anything wrong in my coding and how can I read ms.word
file and display included content in this file??
all answers will be appreciated.I have figured out how to use Object in Word to embed the SWF file and use the Control Box to activate it, however, like you when I convert to Acrobat PDF from the Word Add-in it does not embed the SWF in a playable format, although the object is there. I can't seem to get any relevant properties using the Touch Up Object tool either. I hope someone else has a clue. Otherwise I recommend creating your word document with "empty" text boxes that the text will wrap around and then converting to PDF and once in Acrobat embed a Flash object using the Multimedia button.
-
Read Content of javaws.cfg File
Hi,
I want to add some own entries in the javaws.cfg file.
How could I read the content of this file from ma lauched application ???
Any help is welcome!!!
Jensor you could do something like this to get the directory where javaws.jar and javaws.cfg riside.
* Returns the directory where the jar for the specified Class is
* installed.
* @param clazz the class object the Main class.
* @return the directory the .jar file, which contains the Main class.
private static final File getJarInstallDirectory(Class clazz) {
File file = new File(clazz.getProtectionDomain().getCodeSource().getLocation().getFile());
return new File(file.getParent());
then call this method with javax.jnlp.BasicService.class as an argument. That will return a File object representing the directory containing javaws.jar and javaws.cfg.
masa -
Read contents from a blob file
hi all
i have data stored in a blob file
and i want to show the data in the fields
but when i am showing the data i am not getting the data in the desired format
eg
if i have stored a name (Mandar )in the blob file
when displaying in the blob field i am getting something like aaaaabbbjddddd (example)
i am not well versed with this
can u please guide me through it ?
thanks
MandarWhat you are getting is raw format. You need to use:
UTL_RAW.cast_to_varchar2 (p_raw);
in order to make it readable.
Denes Kubicek -
How to read the content of a text file (by character)?
Guys,
Good day!
I'm back just need again your help. Is there anyone knows how to read the content of a text file not by line but by character.
Please help me. Thank you so much in advance.
Jojohttp://java.sun.com/javase/6/docs/api/index.html
package java.io
InputStream.read(): int
Reads the next byte of data from the input stream.
Implementation:
InputStreamReader
An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted. -
Help on how to read the content of an XML file from the payload
I have a receiver channel / mail adapter, that sends e-mails with a XML attachment.
Im trying to write a Bean, that should make it possible to rename the attached XML file dynamically.
In the Bean I want to read the content of the attached XML file, it could be the order number.
The filename should then be Order number.XML.
<u><i>Can anyone help me with how to read the content of the XML file from the payload.</i></u>
<i><b>Frank</b></i>hi,
check this: http://jakarta.apache.org/poi/ -
Can a search engine read the contents of a Library file embedded in a page?
Can a search engine read the contents of a Library file
embedded in a page? Or would SSI be the way to go. I'm creating a
large library of text-based information and links, and I want to
have much of it modular so I can add a link and all the many pages
on my site updates to reflect the change. A big concern is that
when a search engine visits my site, can it read the content
embedded in the library item, or is SSI a better method to help the
search engine read my content?
ThanksYes, search engines can read Dreamweaver library items. The
library only exists on your own hard drive. Once you add the
library item to your pages it's in there as regular HTML.
If you have more than 20 pages on your site, they say SSI is
better, because when you update you only update the SSI. If you
stick with library items each page has to be uploaded every time
the library is updated. -
How to read the content of this excel file in LV
Hi could you please let me know how can I read the content of this excel file using the Read From Speardsheet function. It contains text and numbers
Thanks
The excel file is attached
Attachments:
Datalogging.zip 307 KBCheck attached VI.
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT.
Attachments:
ReadFromExcel.vi 27 KB -
To Read the contents of the properties file which is located in webserver
Hi,
I have one requirement where I have to read the contents of a property file which is located in some path in server. Say for example, when you click on link abcd then contents of abcd.properties file should be displayed in one text view in webdynpro . I am trying to implement this in webdynpro for java. The main thing is like I am not able to retrieve the server path of the file and hence not getting the file contents. I tried using methods like getApplicationPath() or getRealPath() but its not working. So can you guys please help me on to how to read the server file contents.
Thanks and regards,
SaiHi Romano,
Thanks a lot for your reply. However, I forgot to mention one thing in my question. Its like the path will be different everytime. Say, we have systems like development, acceptance, production. So when the user clicks on the link abcd, it should take the path of development system and similarly when the user clicks on the link in acceptance or production, the path will be different. say for example, in development the path will be
usr/cluster/dev/abcd.properties but it acceptance it will be usr/cluster/acc/abcd.properties. So just want to know whether this will work? Anyway, I will give this a try.
Thanks once again,
Sai -
How to read the content of ms-word file use pure java???
how to read the content of ms-word file use pure java???
hi,
check this: http://jakarta.apache.org/poi/
Maybe you are looking for
-
How do I stop Dreamweaver from replaceing " with È while in code view
Here is my problem (DWCS5 Version): I open DreamWeaver and all is fine. I only use code view. As I work I might open .cfm files, or even (it seems) open a browser - and when I return to writing my code, when I type " Dreamweaver types È " is typed as
-
I am getting the following error when i am trying to check in new created content profile
Hi All, I am getting the following error when i am trying to check in new created content profile as: An error has occurred. The stack trace below shows more information. !csUserEventMessage,weblogic,localhost:16200!$!csServiceDataException,CHECKIN_N
-
Creation of New Acct. Determination Transaction keys in OBYC
Hi All How do I create new Acct determination keys in OBYC . i.e. just like FR1,FR2 etc so that I can do my own asignments in pricing procedure and other accurals? I guess it has to start with Z.. Thanks Samuel
-
HP Photosmart C306g Windows7 64 bit When I click on the HP Solutions Center on laptop to scan, I get the Error message "Parsing Error in file C:\ProgramFiles (86)\HP\DigitalImaging\bin\hpqscloc\1033.xml" Worked just fine in the past,not sure when it
-
Currently having several issues: Mac Pro Quad 3GHZ 9GB RAM Logic Pro 7.2.3 OSX 10.4.9 --- Audio appears to go to sleep after 10 minutes of non-use. Half the time loading a blank channel strip on any track (or a full one for that matter) will wake up