Best practice: tar file handling through java on Linux

What would be the better way to handle large size tar files (size may be more 1 GB) on Linux using Java? One way would be by using linux "tar" command through Runtime.exec, another option is through Java zip classes?
Btw, functionality I am doing is extract the large tar file, remove some files and tar it back to make a smaller size tar ball. I am not too sure if Java provides an api to remove individual files/directory from a zip file.

A tar file is not a zip file.
Java provides no classes that handle .tar files by default.
It does provide classes to handle the gzip compression that's often applied to .tar files (resulting in .tar.gz or .tgz files).
So you either search for a library that handles tar files in Java or invoke tar as an external process.

Similar Messages

  • What are the best practices for exception handling in n-tier applications?

    What are the best practices for exception handling in n-tier applications?
    The application is a fat client based on MVVM pattern with .NET framework.

    What are the best practices for exception handling in n-tier applications?
    The application is a fat client based on MVVM pattern with
    .NET framework.
    That would be to catch all exceptions at a single point in the n-tier solution, log it and create user friendly messages displayed to the user. 

  • Is File handling in Java Swing possible?

    Hi I need to know whether file handling in Java Swing is possible or not?

    cents wrote:
    Thanks for ur answer.....Actually I just wanted to know whether "Reading from a file" and "Writing to a file" in Java Swing is possible or not?
    Edited by: cents on Mar 16, 2010 9:35 AMWhat did google tell you? Did you see anything interesting in the API?

  • Best practices for file I/O within producer/c​onsumer loops

    I'm looking to add file recording and playback functionality to a pre-existing data collection program.  The original progam is based on a Moore-style state machine, which I have added four additional states to.  They are: Record Start, Record Stop, Playback Start, and Playback Stop.
    What I have done, and what has since been identified as poor programming practice, was to "initialize" (either create or load) the appropriate file within the state machine loop during the "Start" command (for record or playback functionality), and then provide the file reference as an indicator, which is linked to for the appropriate read or write operation(whether I'm playing back or recording).  The actual I/O occurs within the the Consumer Loop. (screenshots attached).
    This is my first labview project outside of tutorials or other small examples, so any advise and constructive criticisims are welcomed.  Specifically with regards to file IO and refnum routing (it gets a little hairy in the consumer loop)!
    I'm running Labview 8.6 on Vista business.
    Attachments:
    Playback Start.JPG ‏71 KB
    Consumer_Loop.JPG ‏122 KB
    File Playback subvi.JPG ‏14 KB

    jamoore84 wrote:
    Ben,
    Thanks for the suggestion.  I think it's a little outside my ken at this moment, but  I'll look it over.  Despite any grevious coding transgressions, I have experienced some limited success with the current setup.  While the use of Action Engines/Functional Globals may constitute the best practice, I might revise my post to read "acceptable and/or easily absorbable practices" instead.
    Are there any other opinions on this?  Let me start by listing a problem and posing a question:
    Problem:  I am able to playback a file only once.  Subsequent attempts at file playback do not work.
    Thanks in advance,
    jimmy 
    HI Jimmy,
    I don't give up easy.
    Let me try to exaplain the issue with race conditons with a contrived example, the
     "Command by Mail box" case.
    Imagine you had a job where you recieved your orders via an old fashioned mail box. You never really saw your supervisor but relied on getting orders via the mail box. Now imagine the mail box could only hold one message and any time a new message was inserted, the old one would fall into the trash.
    So you come to work each day check your mail box do what was ordered and everyone is happy.
    The next day you come in and without your knowing, you are assigned to do the work of two bosses. So as long as you check your mail box more often than the two of them assigne work everything is fine... until you take a day of vacation! So you come back in the day after vacation and check you mail box and work a way until you catch hell for ignoring orders !?! Wel it turn out the order from boss 1 was replaced by the order from boss 2 while you were on vacation. Oh bother!
    How can we fix it?
    1) Expand the mail box so it hold more than one order. You just process them in the oder they are recieved.
    2) Change to mail box to not accept a new order until you have removed the old.
    Now back to reality!
    Local variables act like the funky mail box. The last message insterted over-rides the previous.
    Multiple variable writer ar like multiple bosses.
    Queues operate like an expanded mail box, letting you handle each message in order.
    Action Engines operate like the "mutexed" mail box.
    Why I don't want to encorage you to "just patch up" what you have.
    All of the less than ideal solutions either over-sample (Check e-mail twice as often as bosses assign work, waste CPU, an exercise in futility if you are coding in a non-Real-Time envirionment like Windows) or use a mutex to control access to the shared resource ( in this case local varialbes).
    LV offers mutexes through semaphores (found on the syncronization pallete) but...
    WHY WORK SO HARD?
    In my AE Nugget I explain that the exection of an AE is automatically protected by LV. So in the long run it will actually be easier to learn how to use the AE programming construct than it will be to learn how to solve the problem without them.
    so GO FOR IT! Take the lazy route and learn how to use the AE construct. Use the Syncronization pallete for Queues.  
    Just trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Best Practices for File Organizati​on/Project Explorer

    So we are finally getting SCC at my organization to manage our LabVIEW development, and that is good! 
    Now, we are starting in on discussions about how we should organize our files on disk and how we should use the Project Explorer. When I started here about 3 years ago, I wasn't very familiar with the project explorer, so I read the article at http://zone.ni.com/devzone/cda/tut/p/id/7197. Two of the main things I took away from that article are:
    1. Organize Files in a logical manner on disk. Whatever that is, it is not a flat file structure.
    2. The top level VI should be separate from other source code. Preferably, it should reside in the application folder.
    Push Back Against These Recommendations
    Before I was hired, most, if not all LabVIEW development was done utilizing a flat file structure and the top level VI lived with the source code. Since we didn't have a proper SCC, each individual organized files as he saw fit. So I started using the Project Explorer (not even its use is totally accepted right now) and I began follow recommendations 1 and 2 above. I didn't always follow #1 very strictly, but I have been working towards it, and I have always followed #2 religiously. 
    Since we are starting these discussions on how we should organize files on disk I'm starting to get some push back to following these two recommendations.
    The arguments I get in favor of using a flat file structure is that you always know where every file is; including the top-level VI. It is also argued that it is a lot of effort to organize and search for VIs when they all reside in different folders. I think the fear is that by getting "clever" and organizing our files in such a manner we'll make things complicated and we will somehow shoot ourselves in the foot. 
    The argument I get against separating the top level VI from the rest of the source code is that it:
    (a) Won't be clear where it is (like it is buried within hundreds of VIs). However, it is argued, you can just put a "!" in front of the file name and then it is always the at top of the flat file structure.
    (b) An extension of argument of (a) is that things either look or seem messy when VIs (including top level VI) don't live in a sub-folder and are just hanging out with the Project Explorer file. 
    (c) I think there may be some fear of breaking the VI by moving it and altering the dependencies for the VI. 
    Convincing Others its Good to Follow These Recommendations
    So, if I want to follow NI's recommendations, I need to come up with reasons we should follow these recommendations. Also, I should state that I care about following these recommendations because its what NI recommends. They've been around the block a few times and I'm sure there are good reasons why these are best practices. However, I don't think I've given a very compelling case for why these recommendations should be followed.
    So I'll tell you all what I think good reasons are for these recommendations and perhaps I can get some feedback or additional support? If I'm crazy for wanting to follow these recommendations maybe someone can point out why I'm crazy. 
    (a) Arguments for Following Both
    I. I passed the CLAD a couple of weeks ago, and I have started studying for the CLD. Part of the CLD is following both of these recommendations (see page 6 of http://ftp.ni.com/evaluation/certification/cld/cld​_exam_prep_guide_english.pdf). While this isn't a reason in and of itself, it suggests that if it important when being certified it is important in practice!
    II. If we hire new developers that are familiar with LabVIEW, they will most likely be familiar with these recommendations, especially if they are certified. That will lead to increased productivity out of the door because they won't have to learn our special way of doing things.
    (b) Arguments for Organized File Structure
    I. Unused VIs are easier to identify and remove. Right now we never remove VIs because we don't know if they are used or not. This leads to a lot of VI bloat.
    II. It is hard to know what a specific VIs function is in a flat file structure by looking at the name.
    (c) Arguments for Separating Top Level VI from Source Code
    I. Placing the top level VI is an intuitive place for this VI. As long as the top level VI is the only VI in the application folder there is no mistake it is the top level VI, especially once you open it. This makes it easy for new developers to find the top level VI. I'd argue it isn't very intuitive for new developers to know that a VI in the source code folder that is prefaced with a "!" is the top level VI.
    Summary
    So that is what I think so far. Is there anything else I am missing to support following those two recommendations or am I just being inflexible?
    Thanks!

    zenthoef,
    As a CLA, I have struggled with file structure over the years.  Here are my recommendations:
    1.  Put the top level VI and the project in the top-level folder.  This makes it very clear where to begin.
    2.  Put the remaining user interface VIs in a separate folder.  Again, it makes it very clear what the functionality of these VIs are.
    3.  If you are using object, put each object in a separate folder.  Place the family of objects in one folder, with each object in a subfolder.
    4.  Keep the remaining VIs either in a single folder.  This can contain a small number of subfolder if your project is large, but too many folders makes it hard to figure out where your VIs are.  For example, you might have a DAQ subfolder, an Analysis subfolder, and a Report subfolder.  But if you had a Test1 folder, a Test2 folder, and you had a VI that was used by both tests, where would it go?  Keep it simple.
    5.  You inferred that it is hard to figure out what a VI does by its name.  That implies that 1) you need better names, and 2) your VIs are too complicated.  A VI should do a single function which can be adequately described by its name.  That VI might be something like Analyze Data.vi, which would contain a bunch more subVIs (like Get 1st Harmonics.vi), but each VI would contain a single function.  You wouldn't save the data to a report in the Analyze Data.vi, for example.
    The most compelling reason for following these suggestions is that it is easier to figure out what the code is doing after you haven't looked at it for a while.  Once you have an application that is working and bug free, you shouldn't have to touch the code until you want to add features.  If that is even 6 months later, you will probably have forgotten how the code works.  As a consultant, I have had to update other people's code, and just figuring how where to start can be a challenge.
    Tom Brass
    Certified LabVIEW Architect
    Saint Bernard Engineering, Inc.
    www.saintbernardengineering.com
    Tom Brass
    Certified LabVIEW Architect
    Saint Bernard Engineering, Inc.
    www.saintbernardengineering.com

  • MS-Word.EXE file invocation through java?

    Is it possible to run winword.exe from the system through
    java. Is there any way to invoke any application file without using the absolute path.

    Hi
    But before using Runtime make sure that u search for Winword.exe. And i had the same requirement for an application which needed Excel file to open up and what we did was search for an Excel Executable and then store the value is properties file and later on use that path for Openeing Excel Files.
    Bye

  • Best practice versioning XI szenario with java proxies

    Our XI scenario includes services with java proxies.
    By changing the message structure, java proxies have to be changed, too. But not all connected application can  migrate to new message structure at the same time.
    I need a solution to run different versions of the same scenario at same time. This is also a requirement to my java proxy service. Thus I need to run the java proxy service under different versions.
    To maintain minor and major changes, what would be the best practice for versioning in XI scenarios and for java proxies?
    Is there a better solution than use different namespaces inside the XI scenarios (e.g. add the version number) and use different EJB-names for the proxy services (e.g. include the version number in the name)?
    Thanx,
    Michael

    Hi Michael,
    I don't have a best practice for you, but...
    In general, you tend to run into trouble when making incompatible changes to message structures. Since the Software Component Version is not used as part of the message key (only interface and namespace is used), you can't use this versioning mechanism to help you. Thus you are forced to create a new interface instead of a new version of the same interface. If you can think up a new name (that won't just cause confusion), fine. Otherwise you are forced to include an version identifier in either the interface name or the namespace. The latter is used in some public XML schema definitions e.g. xCBL. In other words: versioning via namespaces. Not exactly elegant, but perhaps your best bet.
    Best regards,
    Thorsten

  • Best Practices For Dashboard design  through BI

    Hi
      If I want to create a dashboard through BI7 .what is the best way to suggest the client people. Which way SAP recommended for BI7 Best practices for dashboard design.
    Thanks & Regards,
    Praveen

    Sloved

  • Best Practice EPA files...

    Hi,
    i found the the following  EPA files from SAP Best Practices for Portals- V1.70 :
    1)BP_ALL.EPA
    2)BP_EC_ALL.EPA
    3)BP_ECC_BL.EPA 
    ....The question is that whether i can use the "iviews" in these files to give to my users ...or whether this iviews are only for demo purpose(i could see that this are a prototype files)....if this files are a prototype ....can i find the original EPA files...any where else?
    Rgds,
    P.Navakanth

    Apple has already hidden about half of the folders on a typical OS X install. The ones that make up the Unix core of the OS. So unless you know how to find those, you'll never have to worry about them.
    Aside from that, you just want to keep away from the System folder and any of the Library folders. Nothing else should be too crucial to the OS running.
    Of course if you wanted to elaborate on "a little strange" we might be able to be a bit more helpful.

  • Object file handling giving java.io.StreamCorruptedException

    Hi All,
    I am storing and retriving objects from a file. but when i write multiple objects then while reading objects from the file its giving
    java.io.StreamCorruptedExceptionPlease advice. Here's the code
    import java.io.*;
    class Person implements Serializable{
         String name = null;
         int age = 0;
         public void setName(String name){
              this.name = name;
         public String getName(){
              return this.name;
         public void setAge(int age){
              this.age = age;
         public int getAge(){
              return this.age;
    public class ObjectFileRead{
         public static void main(String args[]){
         try{     
         *     Writing the objects to the file
              FileOutputStream out = new FileOutputStream("Person.dat",true);
              ObjectOutputStream objOutStream = new ObjectOutputStream (out);
              for(int i=0;i<5;i++){
                   Person p = new Person();
                   p.setName("MyName:1"+i);
                   p.setAge(10+i);
                   //System.out.println(p.getName());
                   //System.out.println(p.getAge());
                   objOutStream.writeObject (p);
              objOutStream.flush();
              objOutStream.close();
         *     Reading the objects fromt the file;
              FileInputStream inStream = new FileInputStream ("Person.dat");
              ObjectInputStream objInStream = new ObjectInputStream (inStream);
              try{
                   while(true){
                        Person p = (Person)objInStream.readObject();
                        System.out.println(p.getName());
                        System.out.println(p.getAge());
              }catch(EOFException e){
         }catch(Exception e){
              System.out.println(e);
    }

    The output of ObjectOutputStream starts with a header. Because you append to the file Person.dat you end up with multiple headers, but you only open one ObjectInputStream. One approach would be to create a new ObjectInputStream wrapping inStream after every 5 objects read. I suspect a better one (because it avoids the risk of ObjectInputStream doing read-ahead and buffering) is to replace the appending with reading the file and writing it out again followed by the new objects.

  • Executing the top command through Java in linux

    I am trying to execute the top command in Java as
    Runtime.getRuntime().exec("top -n 1 >a.log");
    But the command is not working in linux only through java.When i run the same command through the prompt it is working fine.Also all other commands are working fine.Is there any issue with top in linux?

    flounder wrote:
    Try reading [this article|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html]. If it does not answer your problem then try seaching for other similar articles.
    The cited article does provide an answer to the problem since it explains how the shell meta character '>' must be interpretted by a shell. The code as presented does not invoke a shell.

  • Best practice for Web Dynpro for Java to connect to SAP HR

    What is best way to connect Web Dynpro for Java application deployed in SAP portal to connect to SAP HR ?
    Is it good practice to connect to underlying SAP database ( eg oracle) directly to get the data or is there a better way ?
    This below article describes to connect to external DB, however Is there any other way for  SAP HR ?
    http://wiki.sdn.sap.com/wiki/display/WDJava/WebDynproApplciationwithDatabaseMS+Access

    Hi,
    There are 2 supported ways :
    First is  to use JCO connections to call abap RFC enabled function modules. (BAPIs for example)
    Second is to call SOAP web services (HR enterprise services for example)
    You should never access directly database tables...
    Regards,
    Olivier

  • PDF file handling through BPEL

    Hi,
    We are exploring BPEL as an option to handle PDF files generated by Oracle EBS (BI Publisher). Basically we want to achieve following:
    Pick up PDF files from certain location on UNIX box and then
    a. Spliting the PDF file into two or more files (depending on some data on PDF file itself, say customer number)
    b. FTP few of the splitted files to certain location on UNIX
    c. Print few of the splitted files onto a predefined network printer
    d. Upload PDF files in Oracle database (BLOB)
    e. Email/Fax PDF files as attachment to one or more recipient
    I understand this may be a weird requirement but it would be great if we can take advantage of BPEL flexible process management capabilities.
    Please give your inputs (whatever possible) as to whether above listed tasks are possible or not?
    br

    Hi Vanilla,
    I want to process the string that I get from the pdf.What do you mean "process"? What are you planning to do with it?
    And it is NOT a String. If you want a String representation (e.g., just the text, with no layout, font, etc. info), then you'd need to interpret the BYTES first and then build a String from the results.
    I can not process the bytes. So I think, I have to
    convert the bytes into string.Then you need to either learn the PDF spec and write code to interpret those bytes, or you need to find a 3rd party library that does this. You can't just expect to read the bytes into a Java String and have it work.

  • What is Considered Best Practice for Error Handling in Components?

    What would be the best approach to handling errors in custom (possibly composite) components?
    I see three different possibilities:
    Having the error handling funciton within the component. The problem is that this is not adaptable to the consumers error handling setup (i.e. logging to database, redirecting to a pretty error screen, etc.).
    Passing in an error function as a parameter. The problem here is how to have the externally defined error function interact with external elements that are not defined within the component, i.e. passing the error or fault object to a logging class, or something similar, of which the component knows nothing about.
    Referencing the external error handling methods directly from within the component. (Of course that's shabby programming, just listing as a technical option.)
    How do you solve this?
    My goal is to have a versatile custom component that can utilize any given consumer's error handler.
    Thanks,
    Mike

    or define a customized event and dispatch it when error occur, then you can just listen to it outside

  • Best practice migrate file server

    I have 3 file servers n two different domains:
    FileS01 and FileS02 in domainA (FileS01 / FileS02: Windows 2003R2)
    FilesS03 in domainB (FileS03: Windows 2003R2)
    Should I migrate to a new
    corporate server to be FileS01 (Windows 2012)
    also call and be in the domainA.
    As you advise me to do it?
    Thanks

    I recommend you consult this guide:
    http://technet.microsoft.com/en-us/library/jj863566.aspx
    Yes, it is a ton of information but it also covers all angles; what to name the servers, when to rename the servers, using DFSN to make things smoother, the migration tools, migrating local users, etc.  Due to the sheer amount of information, ignore
    the areas that don't apply to your implementation (BrancheCache, as an example.)  HOWEVER, I do recommend you consider their suggestion to move this into a DFS Namespace. That way the next time you need to move to a new server, the users will barely feel
    it.
    Best of luck. 

Maybe you are looking for

  • How to get Printing in Windows 7 via PDF to work

    I have just installed SSGD on a 32 bit RedHat without any problems. I need access to Windows 2008 and Windows 7 VM's running in a VMware farm. If I connect from a Windows 7 Client running IE8 and Java to the windows server, I get the right PDF printe

  • Automatic reset of ActionTec MI424WR router

    Has anyone experienced an auto-reset of the MI424WR router?  Two days ago, my router stopped connecting with the wireless devices on my home network, and I ultimately determined that the router had reset --- on its own --- to the default settings.  I

  • Controlling an existing application via webservices

    Hi all, I just came across labview webservices whilst at one of the NI Tech symposiums in the UK last week and I want to use them for a specific application. However my initial playing hasn't worked very well! I want to know if I'm doing something wr

  • How to get the vmdetails in VirtualBox

    Hi, I am using "VBoxManage metrics query <vmname>" command to collect the metrics of quest vm. But i need the difference between CPU/Load/User and Guest/CPU/Load/User. I want to know the cpu utilization of guest against allocation of cpu from host. P

  • On Leopard, iCalalarmscheduler doesn't exist anymore right?

    Greetings, Over the past few weeks I thought I had problems with my reminders in iCal and alarms didn't work but I had made a couple of "Alarm" mistakes. I understand that now. However, during all this time I thought I was missing a few selected file