Using PrintWriter for writing to file

Friends,
I am just begginer in Java programming. I am trying to write a message to the Log file as below. It just opens the file but writes nothing to it. What is missing here ? any help is appreciated.
FileWriter fw = new FileWriter(new File("Readonly.log"));
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
pw.flush();
String message="Check This Out";
pw.println(message) ;
Thanks,

Friends,
I am trying to write to a log file in the append
mode. It seems FileWriter would open the file as a
new file each time and overwrite the eralier contents
of it. I am not sure what would be the correct way
to do this.
Can any one help ? I appreciate your time and help
in advance.
Thanks,Then I doubt you're using the proper FileWriter constructor. I'm sure if you pass 'true' for the append parameter, it will not overwrite the contents.

Similar Messages

  • Using Log4j for writing files

    Hello,
    Is possible to use log4j for writing files?
    For example:
    I have an application that produce several report txt files is possible at runtime produce them using log4j features?
    Thanks

    Did you ever got an answer for this??? I'm starting a new project with ORACLE 9i and the site have a NAS. It will be very helpfull to know if it's possible and how can it be done.
    Thank you,
    Ulises Feliciano Troche
    GIS Analyst
    GMT

  • How do I restore IE to use Reader for displaying PDF files?

    When I updated PDF Creator, it also updated PDF Architect which went and installed itself in IE as the PDF reader.  How do I change IE back to using Reader for displaying PDFs?
    In IE, I disabled the "PDF Architect Internet Explorer Previewer" under "Manage Addons".  Now, IE doesn't display PDFs at all.  I also looked in Change PC Settings | Search and Apps | Defaults and Reader is still the
    listed as the default app for .PDF files.
    The version of Windows on this machine is Windows 8.1 with IE 11.
    Thanks,
    Richard

    first please make sure reader app still there, try to search using keyword "reader"
    If still there, to set reader app as default
    http://windows.microsoft.com/en-us/windows-8/reader-app-faq
    If PDF, XPS, or TIFF files are opening in another app, you can tell Windows to use Reader instead. Here's how:        
    Swipe in from the right edge of the screen, and then tap Settings.
    (If you're using a mouse, point to the lower-right corner of the screen, move the mouse pointer up, and then click
    Settings.)            
    Tap or click Change PC settings.            
    Tap or click Search and apps, and then tap or click Defaults.            
    Tap or click Choose default apps by file type (you might need to scroll down to the bottom of the screen to see this option).            
    Under Name, scroll down until you see .pdf.            
    Tap or click the name of the app that appears to the right of .pdf, and then under
    Choose an app, tap or click Reader.            
    Repeat this for each type of file that you want to open in Reader (for example, .oxps, .xps, or .tiff).
    If not there, or you accidently remove it, try to download here
    http://apps.microsoft.com/windows/en-us/app/reader/8a4ae377-a4ab-4260-9b80-f9382360e291

  • Using SQ02 for writing ABAP programs

    Hello,
    I am using SQ02 coding section for writing some simple ABAP programs, mainly for reporting purposes. I would like introduce more power into my programs, but SQ02/SQ01 reports return "ACCESS_DENIED" when I for example try to call a function (GUI_DOWNLOAD).
    Can You advise how to extend SQ02 authorization to enable function calls?
    Maybe You know other place from which You can write programs without a developer key?
    Thanks,
    Pawel

    Hi Uday,
    do You mean that I have to first make a recording on cg3y using transaction shdb, then create a function module basing on this recording, and then use this function module in my code?
    Pawel

  • Linking error when using C++ DLL for writing TDM files

    I try to integrate TDM into my C++ code. Then I downloaded the package from the NI website "Integrating TDMS in Third-Party Products". I tested the the sample "writeFile.c". But a  linking error as following occurred:
    1>Linking...
    1>nilibddc.lib(implib.obj) : error LNK2019: unresolved external symbol __imp__wsprintfA referenced in function _LoadDLLIfNeeded
    1>.\Debug/Test TDM.exe : fatal error LNK1120: 1 unresolved externals 
    Can anyone help me out. Many thanks. 
    Solved!
    Go to Solution.

    I migrated my code from VC++ 6 compiler to VC++ 2005. Then linking errors are gone.
    nilibddc.lib(implib.obj) : error LNK2001: unresolved external symbol ___security_cookie
    nilibddc.lib(implib.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
    P.S. "Read me" from NI says "The Microsoft 32-bit format is compatible with Microsoft Visual C version 6.0". But I tested the code with VC++6 professional with SP6 package and upgrade the SDK to the latest version that supports vc6. I still have the linking errors. My test seems prove that the dll does not support VC6. 
    Message Edited by Kuo on 04-22-2010 05:03 AM

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • Help needed in using POI for manipulating Word files

    Hi ,
    I am new to POI. I have to take multiple files as input and write them to an output word file using POI.The input files may be word files, jpg or or any other image files and excel sheets also.
    Is this possible using POI?Is there any example source code available?
    I had another concern .I have downloaded the poi-bin-2.5.1-final-20040804 jar.
    This does not contain any api for hwpf.Where can i find hwpf api?

    HWPF is not included in the standard jar that you will download from the Apache Organisations site. Instead, you need to visit what they tern the scratchpad area - from where the developers grab source to work on - and download HWPF from there. You will have to compile it yourself as well I believe. There is some good news however, I cannot remember the address of the site but I did find a web page with links to pre-built jar's of this area, just have a search with google.
    From my own experiences, I would also reccommend that you look to using JExcel to manipulate Excel worksheets. It does not have the same sort of support for evaluating formulae as HSSF does but it does other things better IMO; little things like exposing the formatting applied to the cell.

  • Using B2B for sending PAYMUL files in EDIFACT format

    Hi B2B Gurus,
    One of our client has the following requirement.
    1) Create Payment batches in Oracle AP and Format the payments using an EDI format program.
    2) Translate the EDI format file into PAYMUL EDIFACT format.
    3) Send the PAYMUL file across to the bank and receive the acknowledgments.
    At the moment our client uses the services of a third party vendor to take care of the EDI translation, document management and transportation
    features.
    Would it be possible to achieve the above requirement using Oracle B2B Integration + Adapters?
    If yes, would request you to provide me with the Adapters we need to buy (license required) and also the components that would be required to achieve the above functionality.
    Thanks and Regards,
    B2B Naive
    Edited by: user5546779 on Feb 9, 2010 11:05 PM

    Hi,
    Oracle B2B can translate the EDI XML to native EDI format and vice-versa. It has support for both the flavours of EDI - EDIFACT and X12. It has the support for almost all the transport protocols as well. Moreover, for any customization, there is facility of java callouts as well.
    Would it be possible to achieve the above requirement using Oracle B2B Integration + Adapters?From the high level requirement you posted, I can say that it is very much possible to achieve this using Oracle Integration B2B product only.
    If yes, would request you to provide me with the Adapters we need to buy (license required) and also the components that would be required to achieve the above functionality.Now this will vary as per your network design, solution design and detailed requirements but at high level you need to buy only Oracle B2B. First of all you should decide the scope and requirements and then go for estimation. After that decide whether you may go with 10g version or you need 11g (as it has various supports which are not there in 10g).
    For the start, below documents may help you out -
    http://www.oracle.com/technology/products/integration/b2b/pdf/edi_cookbook_oracle_b2b.pdf
    http://www.oracle.com/technology/products/integration/b2b/pdf/B2B_TN_002_B2B_Standards_Supported.pdf
    http://www.oracle.com/technology/products/integration/b2b/pdf/B2B_TN_014_Questionaire_Sizing.pdf
    http://www.oracle.com/technology/products/integration/b2b/pdf/B2B_TN_015_Questionaire_SI_Assessement.pdf
    http://www.oracle.com/technology/products/integration/b2b/pdf/B2B_TN_016_Questionaire_Trading_Partner.pdf
    http://www.oracle.com/technology/products/soa/b2b/collateral/b2b_11g_ds.pdf
    http://www.oracle.com/technology/products/integration/b2b/Oracle_B2B_10g.html
    Regards,
    Anuj

  • Need to use BPM for proxy tp file

    Hi All,
    i am using proxy to file . in this i taking the hole data from sap tables and sending to file.
    i am sending from R3 side is near abt more than 100KB so it is not reaching to pi it failing it self in R3 side.
    for this can we use pi andfor this can i spilt the source message into 50KB ,50 KB and then collect into BPM and send it to in one file.
    Regards
    Edited by: gangadhar kh on Dec 7, 2009 12:10 PM

    Hi Gangadhar,
    Performance wise we don't suppose to send that large amount of files at a time through XI, what we can do is we have to split those large messages into smaller messages and send to PI and sap recommended this.
    Check this links
    /people/alessandro.guarneri/blog/2007/02/21/sap-xi-acting-as-a-huge-file-mover
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417300)ID0036274150DB10726721545819601349End?blog=/pub/wlg/14425  (check second option here)
    /people/udo.paltzer/blog/2008/11/03/real-life-customer-examples-for-high-volume-scenarios-with-sap-netweaver-process-integration
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417300)ID0036274150DB10726721545819601349End?blog=/pub/wlg/5899  - (Zipping the file after receive unzip the file)
    Regards
    Ramesh

  • Using Mockito for writing ATG test case

    Hi,
    Does anyone have idea about writing unit test case for ATG using Mockito? I came across following discussions while goggling -
    https://forums.oracle.com/thread/2531576
    http://stackoverflow.com/questions/9373782/using-powermock-to-obtain-the-atg-nucleus-in-testing-results-in-npe
    But need a help in setting up Nucleus and other dependencies (DAS, DPS, DSS etc.) and a sample test class for a droplet using Mockito.
    Thanks.

    Forget it. Found ExternalizableHelper.toBinary and fromBinary.

  • Using JSplitPane for Comparing two Files/Contents

    Hi Java Gurus,
    I want to develope a Comparison tool which compares 2 jar files and report the difference in a user friendly manner. Everything is fine and i selected the JSplitPane to display the difference report. I face some problems in doing it exactly simillar way of presenting like a Comparison tools which is there in VSS.
    I created 2 panels and added in a splitpane.
    one panel contains the content of first jar file and another panel contains the content of second jar file.
    The content are added in a textarea and the textarea is added to a scrollpane, which is added to the panel.
    If i fix some size to Textarea, when i expand the Splitpane, the size is not getting expanded accordingly.
    if i remove the size for textarea, the content is not displayed.
    Can anyon give some suggestion.
    Have anybody developed a GUI using JSplitPane simmilar to any Difference Tool simillar to VSS.
    expecting your replies.
    Raffi

    Hi,
    Eventhough the left and right pane are not synchronized, It is showing the Differences.
    I have changed the JTextArea to JTextPane to have control on each of the String i am inserting.
    It is fine. but when i am doing the comparison for the second time, i am removing the content of the Document (of the JTextPane) and adding the new Content to the Document (of the JTextPane).
    While i am printing the length and text after removing the Old Content (in console), i am getting 0, "". But in the GUI old content are not removed and new content keeps on appending, eventhough i do updateUI() and validate().
    Is that a BUG of JTextPane?????????????
    Can any One Figure it out.
    My Code is Here:
    import java.io.*;
    import java.util.zip.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    * put your documentation comment here
    public class CheckZipFile extends JFrame {
    private JLabel firstZip = null;
    private JLabel secondZip = null;
    private JTextField firstZipName = null;
    private JTextField secondZipName = null;
    private JButton compare = null;
    private JPanel mainPanel = null;
    private JFileChooser fileChooser = null;
    private JButton chooseButton1 = null;
    private JButton chooseButton2 = null;
    private StringBuffer buffer = null;
    private StringBuffer buffer1 = null;
    private StringBuffer buffer2 = null;
    private ApolloFileFilter zipFilter;
    private JTextPane first = null;
    private JTextPane second = null;
    private Document doc1 = null;
    private Document doc = null;
    * put your documentation comment here
    public CheckZipFile () {
    initialize();
    buildGUI();
    addWindowListener();
    setLookAndFeel();
    this.pack();
    * put your documentation comment here
    private void initialize () {
    buffer = new StringBuffer();
    buffer1 = new StringBuffer();
    buffer2 = new StringBuffer();
    zipFilter = new ApolloFileFilter(new String[] {
    "zip", "jar"
    }, "ZIP and JAR Files");
    fileChooser = new JFileChooser(new File("c:\\"));
    //fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.addChoosableFileFilter(zipFilter);
    * put your documentation comment here
    private void setLookAndFeel () {
    try {
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    SwingUtilities.updateComponentTreeUI(this);
    if (fileChooser != null) {
    SwingUtilities.updateComponentTreeUI(fileChooser);
    } catch (UnsupportedLookAndFeelException exc) {
    System.out.println("Unsupported Look And Feel:" +
    exc);
    } catch (IllegalAccessException exc) {
    System.out.println("IllegalAccessException Error:"
    + exc);
    } catch (ClassNotFoundException exc) {
    System.out.println("ClassNotFoundException Error:"
    + exc);
    } catch (InstantiationException exc) {
    System.out.println("InstantiateException Error:"
    + exc);
    * put your documentation comment here
    private void buildGUI () {
    mainPanel = createPanel();
    this.getContentPane().setLayout(new BorderLayout());
    this.getContentPane().add(mainPanel, BorderLayout.CENTER);
    this.getContentPane().add(createDifferencePanel(), BorderLayout.SOUTH);
    this.setSize(700, 450);
    SwingUtilities.updateComponentTreeUI(this);
    * put your documentation comment here
    * @return
    private JPanel createPanel () {
    JPanel main = new JPanel() {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(300, 90);
    main.setLayout(new GridLayout(3, 3));
    firstZip = new JLabel("First Jar/Zip File:") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(firstZip);
    firstZipName = new JTextField() {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(firstZipName);
    chooseButton1 = new JButton("Choose File 1") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(chooseButton1);
    chooseButton1.addActionListener(new ButtonListener());
    secondZip = new JLabel("Second Jar/Zip File:") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(secondZip);
    secondZipName = new JTextField() {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(secondZipName);
    chooseButton2 = new JButton("Choose File 2") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(chooseButton2);
    chooseButton2.addActionListener(new ButtonListener());
    JLabel temp1 = new JLabel("") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(temp1);
    compare = new JButton("Compare") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    compare.addActionListener(new ButtonListener());
    main.add(compare);
    JLabel temp2 = new JLabel("") {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(100, 30);
    main.add(temp2);
    return main;
    * put your documentation comment here
    * @param fileContent1
    * @param fileContent2
    private void updateGUI (String fileContent1, String fileContent2) {
    System.out.println("Came here UpdateGUI");
    updateDifferencePanel(fileContent1, fileContent2);
    System.out.println("Came here UpdateGUI after call");
    SwingUtilities.updateComponentTreeUI(this);
    * put your documentation comment here
    * @return
    private JSplitPane createDifferencePanel () {
    JPanel firstPanel = new JPanel() {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(350, 360);
    first = new JTextPane();
    initStylesForTextPane(first);
    doc1 = first.getDocument();
    JScrollPane scroll1 = new JScrollPane(first);
    scroll1.setPreferredSize(new Dimension(325, 360));
    scroll1.setMinimumSize(new Dimension(100, 100));
    firstPanel.add(scroll1);
    first.updateUI();
    first.validate();
    JPanel secondPanel = new JPanel() {
    * put your documentation comment here
    * @return
    public Dimension getPrefferedSize () {
    return new Dimension(350, 360);
    second = new JTextPane();
    initStylesForTextPane(second);
    doc = second.getDocument();
    JScrollPane scroll2 = new JScrollPane(second);
    scroll2.setPreferredSize(new Dimension(325, 360));
    scroll2.setMinimumSize(new Dimension(100, 100));
    secondPanel.add(scroll2);
    second.updateUI();
    second.validate();
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    firstPanel, secondPanel);
    splitPane.setDividerLocation(0.5);
    splitPane.updateUI();
    splitPane.validate();
    splitPane.setPreferredSize(new Dimension(700, 360));
    return splitPane;
    * put your documentation comment here
    * @param fileContent1
    * @param fileContent2
    private void updateDifferencePanel (String fileContent1,
    String fileContent2) {
    System.out.println("Came here");
    try {
    doc1 = first.getDocument();
    System.out.println("Text bef: " + first.getText());
    System.out.println("Length bef: " + doc1.getLength());
    doc1.remove(0, doc1.getLength());
    System.out.println("Length aft: " + doc1.getLength());
    System.out.println("Text aft: " + first.getText());
    doc1.insertString(doc1.getLength(), "test", first.getStyle("regular"));
    first.updateUI();
    first.validate();
    } catch (BadLocationException ble1) {
    ble1.printStackTrace();
    StringTokenizer tokens1 = new StringTokenizer(fileContent1,
    String token1 = "";
    String text1 = "";
    String differs1 = "false";
    int indexOfColon1 = -1;
    int count1 = 0;
    while (tokens1.hasMoreTokens()) {
    token1 = (String)tokens1.nextToken();
    count1++;
    indexOfColon1 = token1.lastIndexOf(":");
    text1 = token1.substring(0, indexOfColon1);
    differs1 = token1.substring(indexOfColon1 + 1);
    try {
    if (count1 == 1)
    System.out.println("Start: " + doc1.getLength());
    if (differs1.equals("true"))
    doc1.insertString(doc1.getLength(), text1
    + ":", first.getStyle("bold"));
    else
    doc1.insertString(doc1.getLength(), text1
    + ":", first.getStyle("regular"));
    if ((count1%3) == 0)
    doc1.insertString(doc1.getLength(), "\n",
    first.getStyle("regular"));
    } catch (BadLocationException ble1) {
    ble1.printStackTrace();
    first.updateUI();
    first.validate();
    try {
    System.out.println("Length bef: " + doc.getLength());
    doc.remove(0, doc.getLength());
    System.out.println("Length aft: " + doc.getLength());
    second.updateUI();
    second.validate();
    } catch (BadLocationException ble1) {
    ble1.printStackTrace();
    StringTokenizer tokens = new StringTokenizer(fileContent2,
    String token = "";
    String text = "";
    String differs = "false";
    int indexOfColon = -1;
    int count = 0;
    while (tokens.hasMoreTokens()) {
    token = (String)tokens.nextToken();
    count++;
    indexOfColon = token.lastIndexOf(":");
    text = token.substring(0, indexOfColon);
    differs = token.substring(indexOfColon + 1);
    try {
    if (differs.equals("true"))
    doc.insertString(doc.getLength(), text +
    ":", second.getStyle("bold"));
    else
    doc.insertString(doc.getLength(), text +
    ":", second.getStyle("regular"));
    if ((count%3) == 0)
    doc.insertString(doc.getLength(), "\n",
    second.getStyle("regular"));
    } catch (BadLocationException ble) {
    ble.printStackTrace();
    second.updateUI();
    second.validate();
    * put your documentation comment here
    * @param textPane
    protected void initStylesForTextPane (JTextPane textPane) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = textPane.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");
    Style s = textPane.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);
    s = textPane.addStyle("bold", regular);
    StyleConstants.setBold(s, true);
    s = textPane.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);
    s = textPane.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);
    s = textPane.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    StyleConstants.setIcon(s, new ImageIcon("images/Pig.gif"));
    s = textPane.addStyle("button", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    JButton button = new JButton(new ImageIcon("images/sound.gif"));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.addActionListener(new ActionListener() {
    * put your documentation comment here
    * @param e
    public void actionPerformed (ActionEvent e) {
    Toolkit.getDefaultToolkit().beep();
    StyleConstants.setComponent(s, button);
    * put your documentation comment here
    private void addWindowListener () {
    this.addWindowListener(new WindowAdapter() {
    * put your documentation comment here
    * @param we
    public void windowClosed (WindowEvent we) {
    CheckZipFile.this.dispose();
    System.exit(1);
    * put your documentation comment here
    * @param we
    public void windowClosing (WindowEvent we) {
    CheckZipFile.this.dispose();
    System.exit(1);
    * put your documentation comment here
    * @param argv[]
    * @exception Exception
    public static void main (String argv[]) throws Exception {
    CheckZipFile compareZip = new CheckZipFile();
    compareZip.pack();
    compareZip.setVisible(true);
    * put your documentation comment here
    public class ButtonListener
    implements ActionListener {
    * put your documentation comment here
    * @param ae
    public void actionPerformed (ActionEvent ae) {
    if (ae.getSource() == chooseButton1) {
    int retval = fileChooser.showDialog(CheckZipFile.this,
    "Select");
    if (retval == JFileChooser.APPROVE_OPTION) {
    File theFile = fileChooser.getSelectedFile();
    if (theFile != null) {
    File[] files = fileChooser.getSelectedFiles();
    if (fileChooser.isMultiSelectionEnabled()
    && files != null && files.length > 1) {
    String filenames = "";
    for (int i = 0; i < files.length; i++) {
    filenames = filenames + "\n"
    + files.getPath();
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose these files: \n"
    + filenames + "\n Multiple Selection Should not be done here");
    else if (theFile.isDirectory()) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose this directory: "
    + fileChooser.getSelectedFile().getPath()
    + "\n Please select a Zip File or jar File");
    else {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose this file: " +
    fileChooser.getSelectedFile().getPath());
    firstZipName.setText(fileChooser.getSelectedFile().getPath());
    return;
    else if (retval == JFileChooser.CANCEL_OPTION) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "User cancelled operation. No file was chosen.");
    else if (retval == JFileChooser.ERROR_OPTION) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "An error occured. No file was chosen.");
    else {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Unknown operation occured.");
    if (ae.getSource() == chooseButton2) {
    int retval = fileChooser.showDialog(CheckZipFile.this,
    "Select");
    if (retval == JFileChooser.APPROVE_OPTION) {
    File theFile = fileChooser.getSelectedFile();
    if (theFile != null) {
    File[] files = fileChooser.getSelectedFiles();
    if (fileChooser.isMultiSelectionEnabled()
    && files != null && files.length > 1) {
    String filenames = "";
    for (int i = 0; i < files.length; i++) {
    filenames = filenames + "\n"
    + files[i].getPath();
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose these files: \n"
    + filenames + "\n Multiple Selection Should not be done here");
    else if (theFile.isDirectory()) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose this directory: "
    + fileChooser.getSelectedFile().getPath()
    + "\n Please select a Zip File or jar File");
    else {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "You chose this file: " +
    fileChooser.getSelectedFile().getPath());
    secondZipName.setText(fileChooser.getSelectedFile().getPath());
    return;
    else if (retval == JFileChooser.CANCEL_OPTION) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "User cancelled operation. No file was chosen.");
    else if (retval == JFileChooser.ERROR_OPTION) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "An error occured. No file was chosen.");
    else {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Unknown operation occured.");
    if (ae.getSource() == compare) {
    String file1 = firstZipName.getText();
    String file2 = secondZipName.getText();
    if (file1 == null || file2 == null) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Enter / Select the Files to be compared");
    return;
    if (file1.equals("") || file2.equals("")) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Enter / Select the Files to be compared");
    return;
    try {
    ZipFile zip1 = new ZipFile(file1);
    ZipFile zip2 = new ZipFile(file2);
    int size1 = zip1.size();
    int size2 = zip2.size();
    if (size1 != size2) {
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Size of both the jars are not same");
    return;
    Enumeration entries1 = zip1.entries();
    Enumeration entries2 = zip2.entries();
    ZipEntry entry1 = null;
    ZipEntry entry2 = null;
    String name1 = "";
    String name2 = "";
    long filesize1 = 0;
    long filesize2 = 0;
    long time1;
    long time2;
    //StringBuffer detail = new StringBuffer();
    boolean nameDiffers = false;
    boolean sizeDiffers = false;
    boolean timeDiffers = false;
    buffer.append(file1 + "\t\t\t" + file2 +
    "\n______________________________________________________________________\n");
    //buffer1.append("\t\t" + file1 + "\n");
    //buffer2.append("\t\t" + file2 + "\n");
    int length = buffer.length();
    for (int x = 0; x < size1; x++) {
    nameDiffers = false;
    sizeDiffers = false;
    timeDiffers = false;
    entry1 = (ZipEntry)entries1.nextElement();
    entry2 = (ZipEntry)entries2.nextElement();
    name1 = entry1.getName();
    name2 = entry2.getName();
    filesize1 = entry1.getSize();
    filesize2 = entry2.getSize();
    time1 = entry1.getTime();
    time2 = entry2.getTime();
    if (!name1.equals(name2)) {
    //System.out.println("Name of the Entries in both the Jars are not same:\n"+ entry1.getName() + " : " + entry2.getName() );
    nameDiffers = true;
    //return;
    //else
    //     System.out.println("Name: " +entry1.getName());
    if (filesize1 != filesize2) {
    //System.out.println("Size of the Entries in both the Jars are not same:\n"+ entry1.getSize() + " : " + entry2.getSize() );
    sizeDiffers = true;
    //return;
    if (time1 != time2) {
    //System.out.println("Time of the Entries in both the Jars are not same:\n"+ entry1.getTime() + " : " + entry2.getTime() );
    timeDiffers = true;
    //return;
    if (nameDiffers || sizeDiffers || timeDiffers) {
    if (filesize1 != 0 && filesize2 !=
    0) {
    buffer.append(name1 + ":" +
    filesize1 + ":" + new java.util.Date(time1)
    + "\t" + name2 + ":"
    + filesize2 + ":" +
    new java.util.Date(time2)
    + "\n");
    buffer1.append(name1 + ":" +
    nameDiffers + ";" +
    filesize1 + ":" + sizeDiffers
    + ";" + new java.util.Date(time1).toString()
    + ":" + timeDiffers +
    buffer2.append(name2 + ":" +
    nameDiffers + ";" +
    filesize2 + ":" + sizeDiffers
    + ";" + new java.util.Date(time2).toString()
    + ":" + timeDiffers +
    if (length == buffer.length())
    JOptionPane.showMessageDialog(CheckZipFile.this,
    "Both the Zip / Jar Files are Identical");
    else {
    getToolkit().beep();
    //System.out.println(buffer.toString());
    updateGUI(buffer1.toString(), buffer2.toString());
    getToolkit().beep();
    } catch (Exception ex) {
    ex.printStackTrace();

  • Can not use Parameters for Opening PDF Files

    I can not open pdf with parameter page like: http://example.con/pdf/1.pdf#page=20 that just get result alway open first page. Everyone can help me?

    The PDF Open Parameters do not contain the option to link directly to a bookmark, as was mentioned, but I've developed a script that can add this functionality to your files. Have a look here, if you're interested: http://try67.blogspot.com/2011/06/acrobat-link-to-specific-bookmark-in.html

  • Downloading via XHR and writing large files using WinJS fails with message "Not enough storage is available to complete this operation"

    Hello,
    I have an issue that some user are experiencing but I can't reproduce it myself on my laptop. What I am trying to do it grab a file (zip file) via XHR. The file can be quite big, like 500Mb. Then, I want to write it on the user's storage.
    Here is the code I use:
    DownloadOperation.prototype.onXHRResult = function (file, result) {
    var status = result.srcElement.status;
    if (status == 200) {
    var bytes = null;
    try{
    bytes = new Uint8Array(result.srcElement.response, 0, result.srcElement.response.byteLength);
    } catch (e) {
    try {
    Utils.logError(e);
    var message = "Error while extracting the file " + this.fileName + ". Try emptying your windows bin.";
    if (e && e.message){
    message += " Error message: " + e.message;
    var popup = new Windows.UI.Popups.MessageDialog(message);
    popup.showAsync();
    } catch (e) { }
    this.onWriteFileError(e);
    return;
    Windows.Storage.FileIO.writeBytesAsync(file, bytes).then(
    this.onWriteFileComplete.bind(this, file),
    this.onWriteFileError.bind(this)
    } else if (status > 400) {
    this.error(null);
    The error happens at this line:
    bytes = new Uint8Array(result.srcElement.response, 0, result.srcElement.response.byteLength);
    With description "Not enough storage is available to complete this operation". The user has only a C drive with plenty of space available, so I believe the error message given by IE might be a little wrong. Maybe in some situations, Uint8Array
    can't handle such large file? The program fails on a "ASUSTek T100TA" but not on my laptop (standard one)
    Can somebody help me with that? Is there a better way to write a downloaded binary file to the disk not passing via a Uint8Array?
    Thanks a lot,
    Fabien

    Hi Fabien,
    If Uint8Array works fine on the other computer, it should not be the problem of the API, but instead it could be the setting or configuration for IE.
    Actually using XHR for 500MB zip file is not suggested, base on the documentation:
    How to download a file, XHR wraps an
    XMLHttpRequest call in a promise, which is not a good approach for big item download, please use
    Background Transfer instead, which is designed to receive big items.
    Simply search on the Internet, and looks like the not enough storage error is a potential issue while using XMLHttpRequest:
    http://forums.asp.net/p/1985921/5692494.aspx?PRB+XMLHttpRequest+returns+error+Not+enough+storage+is+available+to+complete+this+operation, however I'm not familiar with how to solve the XMLHttpRequest issues.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • No more than 8Mbps for writing files with TC !

    Hello,
    I just buy a brand new TC 3To. Internet bandwith is great (more than 80Mbps), but no more than 8 Mbps for writing a file between my mac and the Time Capsule.
    How can you explain that ?
    Thx

    Test it with ethernet not wireless if you are on wireless.
    What computer are you copying the files to the TC with? What OS and how are you copying?
    Is it one large file or a bunch of small files.. the later can be really slow due to time it takes to write allocation table info, cf the actual copy.. the best test is one very large file.. 2GB or so that you copy.. Make sure you do not copy files to the sparsebundle that TM made.. Make sure TM is not running when the files are being copied.

  • Writing to file

    public static void main(String args[]) throws Exception
    String str1;
    int length;
    BufferedReader inpu=new BufferedReader(new InputStreamReader(System.in));;
    System.out.println("Enter something: ");
    str1=inpu.readLine();
    System.out.println("hai"+" "+str1);
    i ve used the above code to read an input from the user now i want to write this to a file.plz tell me how to do it

    ya i tried using FileWriter
    But is there any other methods
    import java.io.*;
    class readtofile
    public static void main(String args[]) throws Exception
    String str1;
    int length;
    //stream given to inputstream reader then buffered usin buffered reader
    BufferedReader inpu=new BufferedReader(new InputStreamReader(System.in));;
    System.out.println("Enter something: ");
    str1=inpu.readLine();
    System.out.println("hai"+" "+str1);
    //opening a new file for output
    File outfile_1= new File("testout.txt");
    //using filewriter class for writing to file
    FileWriter out= new FileWriter(outfile_1);
    out.write(str1);
    out.close();
    }

Maybe you are looking for

  • How can i get icloud password for a deceased relative ?

    Hi My name is Robert Younkin and I had a sister named Nancy Younkin    my sister passed away on 7/25/13 and I have her ipad  but I am unable to have it reset to  original factory settings because I do not have a password for her icloud account. pls a

  • Sender Channel Connection problem

    Hi , I am getting the following error in the Adapter monitoring under RWB. <b> Error: ConnectException: Connection refused: connect - 2007-05-04 09:41:42 CEST: Processing started</b> This happen all out of a sudden. I changed nothing in the Sender CC

  • Yosemite problem with MSW 2011

    I have MSW 2011 version 14.4.4 Sense installing Yosemite, I am not able to use the "enter/return" in a word document. For example, using bullet point in a document, you cannot create a new bullet point. Thanks for any and all advice.

  • How can I get elements 11 to work with 16 bits photos?

    In the expert mode of Photoshop Elements 11, I can only work with 8 bits photos. How can I get Elements 11 to work with 16 bits photos?

  • Fixed and variable cost component break up in PCA

    Hi, Is it possible to get fixed and variable cost component break up and contribution report in PCA at each product group level and lower level of node. I think this requires development. As my client requires the report to have cost break up into fi