Java read .plist files

please help me on how to read .plist files by java. I want to detect an application on .plist. Thanks a lot.

Plist files are just text files. You can open them with any text editor
http://en.wikipedia.org/wiki/Property_list

Similar Messages

  • Can no longer read plist files

    I've got a script that iterates through a list of hostnames, connects to each host, looks for the existence of a list of applications, and if they exist reads their Info.plist for the version.  This worked seamlessly until a couple of days ago.  The only change I can think of is having changed my username on all of my Macs from <username> to <username>.sa to differentiate privileged accounts from unprivileged accounts.  Yes, this caused a number of issues, and I've hunted them down.  I can connect to every host with <username>.sa, perform actions with sudo, etc.  What I can't do any more is read plist files, even when logged in locally:
    quad:~ username.sa$ defaults read /Applications/Utilities/Adobe\ Flash\ Player\ Install\ Manager.app/Contents/Info.plist
    2014-06-26 15:03:59.588 defaults[49157:507]
    Domain /Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/Info.plist does not exist
    quad:~ username.sa$ ls -l /Applications/Utilities/Adobe\ Flash\ Player\ Install\ Manager.app/Contents/Info.plist
    -rw-r--r--  1 root  wheel  1344 May 28 12:02 /Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/Info.plist
    quad:~ username.sa$ cat /Applications/Utilities/Adobe\ Flash\ Player\ Install\ Manager.app/Contents/Info.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>BuildMachineOSBuild</key>
      <string>12E55</string>
      <key>CFBundleDevelopmentRegion</key>
      <string>English</string>
      <key>CFBundleExecutable</key>
      <string>Adobe Flash Player Install Manager</string>
      <key>CFBundleIconFile</key>
      <string>FlashPlayerInstaller.icns</string>
      <key>CFBundleIdentifier</key>
      <string>com.adobe.flashplayer.installmanager</string>
      <key>CFBundleInfoDictionaryVersion</key>
      <string>6.0</string>
      <key>CFBundleName</key>
      <string>Adobe Flash Player Install Manager</string>
      <key>CFBundlePackageType</key>
      <string>APPL</string>
      <key>CFBundleSignature</key>
      <string>????</string>
      <key>CFBundleVersion</key>
      <string>14.0.0.125</string>
      <key>DTCompiler</key>
      <string>com.apple.compilers.llvm.clang.1_0</string>
      <key>DTPlatformBuild</key>
      <string>4H1503</string>
      <key>DTPlatformVersion</key>
      <string>GM</string>
      <key>DTSDKBuild</key>
      <string>10K549</string>
      <key>DTSDKName</key>
      <string>macosx10.6</string>
      <key>DTXcode</key>
      <string>0463</string>
      <key>DTXcodeBuild</key>
      <string>4H1503</string>
      <key>NSMainNibFile</key>
      <string>FPIMMain</string>
      <key>NSPrincipalClass</key>
      <string>NSApplication</string>
    </dict>
    </plist>
    The file is there.  It is readable.  I can read it... just not with the 'defaults' command.  This is with all plists on all of my Macs.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

  • How to read Plist files?

    I would like to know how to read a plist file. I have one that do not work properly and i received a message saying that there is a letter (c) that should not be there. Is is possible to take it off?

    Plist files are just text files. You can open them with any text editor
    http://en.wikipedia.org/wiki/Property_list

  • Writing to a file in java, reading the file with C++

    Is there a way that I can write data to a file (such as a sequence of floats, doubles, ints and chars) and then read the file in with a C++ program that will correctly interpret all the data types.
    Thanks,
    Darrin

    Well, in order to make files readable with different languages, you need to pay attention to byte-order. Generally, C++ reads things using the native byte order of the machine the code is running on. Java on the other hand usually uses big endian byte order everywhere. The java.nio package supports different byte orders, and probably would be helpful for your purposes. You should check out NIO API, specifically file channels and byte buffers, and see if that will serve your purposes. If you have any more specific questions, then come on back and post them.
    E. West

  • Unix java reading Windos files

    i have been working on web project for a while, part of it reads files on another windos box. as i am developing the code on windows also, reading files on another windows box seems to be no problem; however, the production code will be running on a unix box, one of us said reading files on a windows box from a unix box will be a problem. heard installing samba on the unix box would solve this problem, yet the sys admin has no idea on what smba is and would not install it. so, i heard there is a thing called jcifs.jar that can be used to solve this potential problem. as i have no experience on this at all, i would certtainly appreciate any input from anyone.
    thanks in advance.

    i need to read from a unix box a file residing on a
    windows directory, a plain text file, and then pass
    it as an File object to another piece od code which
    takes in a File object. so far with jcifs, i can get
    a SambFile instance, i need to turn it into a regular
    File instance so that the other piece of code can use
    it.Yes, I know what you mean. An SmbFile is not a File so you can't pass it to this software. You have two choices: (1) get that software fixed so it can take an InputStream instead of a File (2) copy the data from the SmbFile to a temporary file on your Windows box and use that.
    i know smbfile provides input and output streams but
    i wonder if i can turn the smbfile into a regular
    java io file without saving the file so that the
    performance would be better? is this possible? the
    code that uses the file object complain file not
    found...You could try writing a subclass of File that wraps an SmbFile. There's only a few dozen methods to implement. But then you'd probably find that the software you are feeding tries to do something like "new FileInputStream(yourFile)" which would fail in some peculiar way. You could ask the designers of that other piece of code why they require a File.

  • JAVA Read XML file and modify attribute values based on some conditions

    I have the following XML file "C:/Data.xml".
    If the attributes on Dimension, Metirc, Data date Matches then Add the amount values and remove the duplicate DS node.
    I looked some examples on hashtable/hashmapping but I could not find that meets my creiteria. I appriciate any direction or suggestions on this.
    <ED LG="US">
    <DS name="1" source="A" freq="Day">
    <Dimension name="code" value="3">
    <Metric ref_name="A1-ACT">
    <Data date="2011-03-04T00:00:00" amount="30" />
    </Metric>
    </Dimension>
    </DS>
    <DS name="1" source="A" freq="Day">
    <Dimension name="code" value="3">
    <Metric name="A1-ACT">
    <Data date="2011-03-04T00:00:00" amount="40" />
    </Metric>
    </Dimension>
    </DS>
    <DS name="1" source="A" freq="Day">
    <Dimension name="code" value="3">
    <Metric name="A1-ACT">
    <Data date="2011-03-05T00:00:00" amount="20" />
    </Metric>
    </Dimension>
    </DS>
    </ED>
    Expected Result:
    <ED LG="US">
    <DS name="1" source="A" freq="Day">
    <Dimension name="code" value="3">
    <Metric ref_name="A1-ACT">
    <Data date="2011-03-04T00:00:00" amount="70" />
    </Metric>
    </Dimension>
    </DS>
    <DS name="1" source="A" freq="Day">
    <Dimension name="code" value="3">
    <Metric name="A1-ACT">
    <Data date="2011-03-05T00:00:00" amount="20" />
    </Metric>
    </Dimension>
    </DS>
    </ED>
    thanks
    Edited by: user7188033 on Mar 19, 2011 1:40 PM
    Edited by: user7188033 on Mar 19, 2011 2:01 PM
    Edited by: user7188033 on Mar 19, 2011 2:02 PM

    Use XSLT for transforming the XML document.

  • Reading into plist files

    Hi,
    I'm building an app that relies heavily on reading plist files. I've got the basics down using System Events, for example:
    tell application "System Events"
    set plistFile to "/Library/Preferences/com.domain.prefs.plist"
    set returnVal to (value of property list item "MyValue" of property list file plistFile)
    display dialog returnVal
    end tell
    To extract from the following plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>MyValue</key>
    <string>1000</string>
    </dict>
    </plist>
    But of course I need to read further into plist files, count the number of re-occurrences of certain items and so on. For example, if I wanted to read into the following plist file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>MyValue</key>
    <key>ArrayInfo</key>
    <array>
    <dict>
    <key>Bool</key>
    <true/>
    <key>Value1</key>
    <string>1000</string>>
    </dict>
    <dict>
    <key>Bool</key>
    <true/>
    <key>Value1</key>
    <string>4000</string>>
    </dict>
    </array>
    </dict>
    </plist>
    How can I extract, for example, the number of records within the array and then create an AS list of each re-occurrence of 'Value1' or 'bool'?
    Any help on this or any links to good tutorials will be much appreciated.
    Many thanks.

    Satimage also has a XMLLib osax with terminology to handle property lists, for example:
    set TheOpenPlist to PlistOpen (choose file)
    repeat with x in items of (PlistGet TheOpenPlist key "ArrayInfo")
          log x
    end repeat
    PlistClose TheOpenPlist
    There is documentation and some examples here.

  • Error reading zip file in Java 6

    We have a bespoke installer program that fails, intermittently, in Java 6 on Windows. After installing some files, it then fails with a stack trace like this:
    java.util.zip.ZipException: error reading zip file
         at java.util.zip.ZipFile.read(Native Method)
         at java.util.zip.ZipFile.access$1200(ZipFile.java:29)
         at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:447)
         at java.util.zip.ZipFile$1.fill(ZipFile.java:230)
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
         at java.io.FilterInputStream.read(FilterInputStream.java:90)
         at com.XXXX.trent.installer.Installer.writeStreamToFile(Unknown Source)
         at com.XXXX.trent.installer.Installer.installFile(Unknown Source)
         at com.XXXX.trent.installer.PatchFileInstaller.installFile(Unknown Source)
         at com.XXXX.trent.installer.PatchFileInstaller.installFiles(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller$TpfAction.run(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller.runActions(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller.install(Unknown Source)
         at com.XXXX.trent.installer.TrentInstall$SoftwareInstallStage.install(Unknown Source)
         at com.XXXX.trent.installer.TrentInstall$UpgradeInstallWorker.install(Unknown Source)
         at com.XXXX.trent.installer.PatchInstall$InstallWorker.construct(Unknown Source)
         at com.XXXX.trent.utils.SwingWorker$2.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)The same code works in Java 5 on the same environments that it now fails in Java 6 (1.6.0_16).
    Any ideas?
    Thanks.

    gimbal2 wrote:
    it is not weird, it is a bug in the application. Don't let the upgrade from Java 5 to Java 6 make you believe otherwise.It's a singularly bad exception message though. I would have thought that something from java.util might be a bit more explicit about what the problem is.
    Winston

  • How to read Excel file in java

    Respected sir/madam
    I want to read the values from Excel file in Java program. How can I do that. When I searched over the net I came to know that you can treat Excel file as a Database and write the code as u write for making DB connections .
    I did that but i am getting the following error ..can anybody please help..
    This is the code what i have written
    import java.io.*;
    import java.sql.*;
    public class ReadExcelFile {
    Connection c;
    Statement stmnt;
    public void checkABA_Number()
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection("jdbc:odbc:ExcelTest","",""); // ExcelTest is the DSN name
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from abadata"); // abadata is my Excel file name
    while(rs.next())
    System.out.println(rs.getString(1)+" "+rs.getString(2));
    }catch(Exception e)
    System.out.println(""+e.toString());
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    public static void main(String[] args)
    new ReadExcelFile().checkABA_Number();
    My Excel file starts from the first row and first column and also the first row contains the names of the column.
    It give me the following error..
    java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abadata'. Make sure the object exists and that you spell its name and the path name correctly.
    How can I deal with this.?I have properly selected the worksheet while giving the DSN . Is there any versionig problem with Excel or some drivers are in appropriate..and yes i chose Microsoft Excel Driver (.xsl) from ODBC .
    I created System DSN.
    Can anybody please help me with this ? I will be very gratefull for replies
    Thanks in advance

    here is the code to read excel file
    public void readexel(String filename)
    Connection c = null;
    Statement stmnt = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
    stmnt = c.createStatement();
    String query = "Select * from [Sheet1$]" ;
    ResultSet rs = stmnt.executeQuery( query );
    while( rs.next() )
    System.out.println( rs.getString(1) );
    catch( Exception e )
    System.err.println( e );
    }

  • How to read pdf files using java.io package classes

    Dear All,
    I have a certain requirement that i should read and write PDF files at runtime. With normal java file IO reading is not working. Can any one suggest me how to proceed probably with sample code block
    Thanks in advance.

    hi I also have the pbm. to read pdf file using JAVA
    can any body help meWhy is it so difficult to read the thread you posted in? They say: java.io is pointless, use iText. So why don't you?
    or also I want to read a binary encoded data into
    ascii,
    can anybody give me a hint how to do it.Depends on what you mean with "binary encoding". ASCII's binary encoding, too, basically.

  • Read multiple files and write data on a single  file in java

    Hello,
    I am facing difficulty that I want to read multiple files in java and write their data to a single file. Means Write data in one file from multiple files in java
    Please help me out.
    Naveed.

    algorithm should be something like:
    File uniqueFile = new File();
    for (File f : manyFilesToRead)
       while (readingF)
           write(dataFromF, intoUniqueFile);

  • Can we read a file which is serialized in MFC using Java

    I have a file in which Serialized data is stored using an MFC application (object of CArchive).
    1. Is it possible to read this file using Java and to retrived the data.
    2. Is yes, which all Java-classes will be needed to explored.
    Thanks
    -Vini

    I have a file in which Serialized data is stored
    using an MFC application (object of CArchive).
    1. Is it possible to read this file using Java and to
    retrived the data.Yes.
    2. Is yes, which all Java-classes will be needed to
    explored. It depends on the data that is being retrieved. You need to read the data using whatever Java classes match. You might want to read the tutorial about this:
    http://java.sun.com/docs/books/tutorial/essential/io/datastreams.html
    >
    Thanks
    -Vini

  • Unable to read Properties file from Java code

    Hi,
    The directory structure of my application is as follows:-
    My App
    ++++++ src
    ++++++++com
    ++++++++++readProp.java
    ++++++++resource
    ++++++++++message.properties
    I am trying to read the file as follows:-
    <code>
    public Static final string FilePath="resource.message.properties"
    Here the code to read the file. I tried using the following two techniques but to no use... :(
    File accountPropertiesFile = new File(FacesContext.getCurrentInstance()
    .getExternalContext().getRequestContextPath()
    + FilePath);
    properties.load(externalContext.getResourceAsStream(FilePath));
    </code>
    But none yeild any sucess while reading through the Bean class. please help...

    Your source code isn't there at run time, at least it shouldn't be, so the directory structure you've shown is irrelevant.
    If the file is in the corresponding position under WEB-INF/classes at runtime, the second technique should work, but you need to fix FilePath to agree with what it says under Class.getResource() and friends.

  • How To Read RTF file in JAVA?  Using  iText?

    How To Read RTF file in JAVA?  Using  iText?.....
    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.rtf.*;
    public class RTF3 {
    public static void main(String[] args) {
    // System.out.println("This example generate a RTF file name Sample.rtf");
    // Create Document object
    Document myDoc = new Document();
    try {
    // Create writer to listen document object
    // and directs RTF Stream to the file Sample.rtf
    RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
    // open the document object
    myDoc.open();
    // Create a paragraph
         Paragraph p = new Paragraph();
         p.add("Helloworld in Rtf file..amazing isn't");
         // Add the paragraph to document object
    myDoc.add(p);
    catch(Exception e) {
    System.out.println(e);
    //close the document
    myDoc.close();
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
         at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
         at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
         at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
         at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
         at com.lowagie.text.Document.open(Unknown Source)
         at view.RTF3.main(RTF3.java:23)
    CAN you HELP me?

    import com.lowagie.text.Document;
    import com.lowagie.text.rtf.parser.RtfParser;
    import java.io.FileInputStream;
    String inputFile = "sample.rtf";
    Document document = new Document();
    document.open();
    RtfParser parser = new RtfParser(null);
    parser.convertRtfDocument(new FileInputStream(inputFile), document);

  • Adapter module to read excel file -java code required for PI 7.1

    Hi PI experts,
    I am working on PI 7.1 SP 08.
    I am trying to develope an adapter module to read excel file
    http://wiki.sdn.sap.com/wiki/display/ABAP/AdapterModuleToReadExcelFilewithMultipleRowsandMultiple+Columns
    but here in this wiki , given java code is for pi 7.0 and it is using jar file from PI 7.0
    I tried with using corresponding PI 7.1 files
    com.sap.aii.af.lib.mod.jar:
    sap.comtcloggingjavaimpl.jar:
    com.sap.aii.af.svc_api.jar:
    com.sap.aii.af.cpa.svc_api.jar:
    com.sap.aii.af.ms.ifc_api.jar:
    jave program is not throwing any error in NWDS but After deploying file on server.
    i am getting this errot in communication channel
    2009-12-15 15:47:08 Information AO: Now calling the Convert Method to convert Excel to XML.
    2009-12-15 15:47:08 Error MP: exception caught with cause javax.ejb.TransactionRolledbackLocalException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file
    since i am not a JAVA expert so i am unable to resolve this error
    if some one has already deployed this module for PI 7.1, then please provide me java code for PI 7.1
    Thanks
    sandeep sharma

    hi,
    please try this:
    obj = inputModuleData.getPrincipalData();
    msg = (Message) obj;
    amk = new MessageKey(msg.getMessageId(),msg.getMessageDirection());
    XMLPayload xpld = msg.getDocument();
    Workbook wb = Workbook.getWorkbook((InputStream) xpld.getInputStream());
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+ "<ns0:"msgType" ""xmlns:ns0=\""nameSpace+"\">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++)
    xmldata = xmldata+"<Record>";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++)
    xmldata = xmldata"<"cellNames<i>.getContents()">"cells<i>.getContents()"</"cellNames<i>.getContents()+">";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata"</ns0:"msgType+">"; 
    wb.close();
    byte byt[] = xmldata.getBytes();
    xpld.setContent(byt);
    inputModuleData.setPrincipalData(msg);
    Thanks,
    Mayank

Maybe you are looking for