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();

Similar Messages

  • How to open acrobat in java and compare two files using javacode

    I am absolutely new to use acrobat software in Java. I want to open two pdf files at a time and then compare the differences between them thru java program .
    i am not sure how to do it. iam trying many ways without success.
    I used jre and could open open files using runtime method , but couldn't do comaparision. i..e could't access tools menu (alt+t) Compare two files and <enter>. help in java will be appreciated.
    Pls guide me the steps to use the acrobat library. At http://partners.adobe.com/asn/acrobat i found supporting vb and vc only.
    Any help or links are greatly appreciated.

    iText is an open source PDF library, reads a PDF one page at a time. You could check it out. I've used it for writing/splitting/concatenating PDFs, but not comparing files
    http://www.lowagie.com/iText/
    Scott
    http://www.swiftradius.com

  • How to compare two files using MD5?

    Hi,all:
    How to compare two files to know if they're the same without any difference?I want to use MD5, but I just konw how get a message digest of a string. How to get a message digest of a file? Or there is other method to compare two files?
    Thanks advance!

    This is starting to sound rather a lot like a homework problem.
    An MD5 message digest is simply a 16 byte array. To compare two message digests...
    byte[] md5incoming = ...
    byte[] md5comparison = ...
    if( md5incoming.equals(md5comparison) ) {
       System.out.println("MD5 Checksums match");
    }To find out how to generate an MD5 checksum, please look up MessageDigest in the API documentation, and do a google search for "MD5 java"
    In a networked scenario, there are two issues - firstly the performance in sending copies of files all over the place (imagine if it's a 10Gb file to be compared over a 14.4K modem link, this would take a while). Secondly, the network link itself might insert an error in the file and you'd get a false miss.
    By only sending MD5 digests over the link, you simultaneously reduce the error (shorter files are less likely to be corrupted) and reduce the transmission time (16 bytes takes practically no time to transmit over damp string, let alone any sort of sensible device).
    D.

  • Any diff-like tools for comparing two .vcf (vcard) files?

    Hi all,
    I'm used to keeping contact information backups in .csv form, its just much simpler to parse with sed/awk etc., I have a small home-cooked script to move fields around between Evolution .csv files and JPilot .csv files such that they match (brittle, but worked for me).
    Current Evolution doesn't seem to support csv output anymore, though, and to be honest the brittle-ness of having to hard-code in my scripts which column in the csv was what data always stung a bit. Evolution DOES output vcards, as does J-Pilot. Unfortunately, parsing vcards with sed/awk and the like promises to be real headache-inducing.
    Basically, has anyone heard of tools for comparing .vcf files? Sort of like diff (which works line-by-line on text) but working element by element on .vcf files.

    Daenyth wrote:
    http://search.cpan.org/dist/Text-vCard/ … essbook.pm
    Write one?
    Was afraid the answer was gonna be that.

  • How to compare two files char by char

    Hi,
    I want to compare two files and after Comparison i want all the differences in the new file has to be updated to old file (Without deleteing the contents of the file)?
    Any help will be appriciated.
    Thanks.

    I think i have to elaborate my question�.. for
    example take a file called xyz.xml which contain some
    data which I don�t want to get deleted� after some
    days this file has been modified (i.e. some more data
    has been added) . Now without overwriting the file
    /deleting the earlier contents of file xyz.xml. How
    do I update xyz.xml file?
    Now I think iam clear.
    Thanks.This does not make sense at all! Either your file has been changed or it has not. If it has been changed then there is nothing to do. If it has not been changed then there is nothing to do.

  • How to compare two files in java & uncommon text should print in text file.

    Hi,
    Can any one help me to write Core java program for this.
    How to compare two files in java & uncommon text should print in other text file.
    thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • Linux Diff tool as External tool in Jdev to compare two files

    Hi, I was looking for adding any diff tool to compare two files in Jdev. I added the usual Linux "diff <file1> <file2>" to compare two files. The way I have provided arguments compares a file against itself.
    Program: diff
    Arguments: ${file.name} ${file.name}
    Directory: ${file.dir}
    My requirement to to right click on the two files which I want to compare and the open them in any diff tool.
    Any ideas?
    Regards,
    Ramesh

    Which jdev version?
    I don't see how this can be done. How do you select two files in jdev?
    As you provided the same name as file1 and file2 it's clear that you compare the file to itself.
    Timo

  • How to compare two files in Java & uncommon text should print in Diff text

    Hi All,
    can any one help me to write a java program..
    How to compare two files in Java & uncommon text should print in Diff text file..
    Thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • Function module for transfering a file contents into another?

    Hi all,
       Is there a Function module for transfering a file contents into another?That is the whole content from a file to other??
    Regards,
    Shashank.

    Hi,
    I think there is no such FM. You need to read the data in internal table and then write it in another file.
    Regards,
    Atish

  • [svn] 4214: * Revert revision 4208 for these two files, because I had incorrectly

    Revision: 4214
    Author: [email protected]
    Date: 2008-12-02 13:12:35 -0800 (Tue, 02 Dec 2008)
    Log Message:
    * Revert revision 4208 for these two files, because I had incorrectly
    assumed that a SourcePath always existed.
    tests Passed: checkintests
    Needs QA: YES
    Needs DOC: NO
    Bug fixes: SDK-18282
    API Change: NO
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18282
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/EmbedUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/AtEmbed.java

    Revision: 4214
    Author: [email protected]
    Date: 2008-12-02 13:12:35 -0800 (Tue, 02 Dec 2008)
    Log Message:
    * Revert revision 4208 for these two files, because I had incorrectly
    assumed that a SourcePath always existed.
    tests Passed: checkintests
    Needs QA: YES
    Needs DOC: NO
    Bug fixes: SDK-18282
    API Change: NO
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18282
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/EmbedUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/AtEmbed.java

  • How to RELIABLY compare two File objects?

    Hi java community!
    I have two File objects and I need to know whether they both point to the same file on the system. First, I tried using the equals() method of the File object, but later I found that this often returns false even when file being pointed to by both objects is the same file.
    For example:
      public static void main(String[] args) throws Exception {
        File mFileA = new File("C:\\PROGRA~1\\MYPROG~1\\MYDATA~1.TXT");
        File mFileB = new File("C:\\Program Files\\My Program\\My Data File.txt");
        DataInputStream mInputA = new DataInputStream(new BufferedInputStream(new FileInputStream(mFileA)));
        DataInputStream mInputB = new DataInputStream(new BufferedInputStream(new FileInputStream(mFileB)));
        System.out.println("Contents of file A:");
        while (mInputA.available() > 0) {
          System.out.println(mInputA.readLine());
        System.out.println("\nContents of file B:");
        while (mInputB.available() > 0) {
          System.out.println(mInputB.readLine());
        System.out.println("\nAre file A and file B the same file?");
        System.out.println(mFileA.equals(mFileB) ? "Yes" : "No");
      }Running this gives the following output:
    Contents of file A:
    First line of the file.
    Second line of the file.
    Third and final line of the file.
    Contents of file B:
    First line of the file.
    Second line of the file.
    Third and final line of the file.
    Are file A and file B the same file?
    NoIt seems that the different representation of the paths (short 8.3 file names, vs. long file names) is confusing Java into believing that they are two separate files, even though the example above confirms that they are in fact the same file by showing the contents from input streams derived by the two File objects (which are, needless to say, identical).
    So, does anyone know how to reliably determine whether two File objects point to the same file?
    Cheers,
    Martin

    sabre150 wrote:
    Bren_McGuire wrote:
    Thanks guys.
    I'd just found it too right after I made this post. :p95% of the time the promised Dukes never arrive so thanks for the Dukes.Ditto

  • Using Java for dynamic web page content

    I've currently got a Perl program that I'd like to convert to Java. It merges two files that are stored on a web server and generates a "dynamic" HTML response.
    For example, if I have the following files on the server:
    File1:
    <Comment1>This stuff</Comment1>
    <Comment2>That stuff</Comment2>
    File2:
    <HTML>
    <Comment1><br><Comment2>
    </HTML>
    When I go to the URL
    www.mysite.com\cgibin\merge.pl?file1&file2
    the Perl program will produce a web page saying:
    This stuff
    That stuff
    The major obstical for the rewrite: NO JSP ALLOWED. It's not allowed by the ISP.
    Now for the questions:
    - Could this be done using Java?
    - How could I initiate the Java app and pass it the parameters? (applet tag, access Java inside Perl, use Java Script somehow)
    - Will an applet tag even work for this since the final page is generated completely from other files?
    Thank you very much for your help.

    If your ISP don't support JSP / Servlets,
    1.use any server side technolgy, something like ASP.
    2.Read the files and transform them as Strings (or StringBuffers).
    3.Pass these Strings as parameters to the applet (if you are forced to use java technology, otherwise you can do it using ASP itself).
    4.Construct the required format (content) in your applet.
    Don't forget that the stuff will be in applet but not a complete web page. The ideal solution is asking your ISP to provide JSP engine.

  • How to compare two files in SAP

    Hi All,
    I have downloaded the contents of a custom table in two files and saved in the uncoverted format, now I want to comapre the contents of these files and see if there is any difference in these files or not. So is there any utility in SAP which I can use to compare these two files.
    Thanks,
    Rajeev

    I can think of 3 alternatives -
    1. Write a report to upload the data and then compare the internal table.
    2. Download data in XLS file and use Excel utilities to compare.
    3. Use file compring tools .( Thanks to Thomas - http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools)

  • How to compare two files?

    Folks:
    Is there any utility class or method that I can use to compare the contents of two files? Something like diff comamnd in UNIX.
    Thanks a lot!

    I wrote the following program and it seems to work. Any suggestion is welcome!
    import java.io.*;
    public class ContentComparator
    * Returns <code>true</code> if both input streams byte contents is identical.
    * @param input1
    * first input to contents compare
    * @param input2
    * second input to contents compare
    * @return <code>true</code> if content is equal
    boolean contentsEqual( InputStream is1, InputStream is2, boolean ignoreWhitespace )
    try
    if( is1 == is2 )
    return true;
    if( is1 == null && is2 == null ) // no byte contents
    return true;
    if( is1 == null || is2 == null ) // only one has
    // contents
    return false;
    while( true )
    int c1 = is1.read();
    while( ignoreWhitespace && isWhitespace( c1 ) )
    c1 = is1.read();
    int c2 = is2.read();
    while( ignoreWhitespace && isWhitespace( c2 ) )
    c2 = is2.read();
    if( c1 == -1 && c2 == -1 )
    return true;
    if( c1 != c2 )
    break;
    catch( IOException ex )
    finally
    try
    try
    if( is1 != null )
    is1.close();
    finally
    if( is2 != null )
    is2.close();
    catch( IOException e )
    // Ignore
    return false;
    private boolean isWhitespace( int c )
    if( c == -1 )
    return false;
    return Character.isWhitespace( ( char )c );
    public static void main( String[] args )
    InputStream is1 = null;
    InputStream is2 = null;
    try
    is1 = new FileInputStream( "c:\\file1.txt" );
    is2 = new FileInputStream( "c:\\file2.txt" );
    catch( FileNotFoundException e )
    e.printStackTrace();
    ContentComparator cc = new ContentComparator();
    boolean ifIgnoreWhiteSpace = true;
    boolean ifEqual = cc.contentsEqual( is1, is2, ifIgnoreWhiteSpace );
    System.out.println( "Are those two files equal? " + ifEqual );

  • How to compare two file differnces

    Hi All ,
    I have two files on my presentation server one file will have some errors and another will conatine corrected , Now I have to compare those two files and display the differed recoreds as a list.Please provide me the required code.
    Thank you ,
    Satheesh.

    Somebody has thought of this before...
    http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools
    You don't need a new ABAP program for this.
    Thomas

Maybe you are looking for