Comapring lines between 2 files

In this program I have to compare two each line of two files and output them to the screen if they are different. I believe I should use compareTo here but I don't understand how. I would appreciate any help (the files are loaded through the internet). Thank you.
import java.util.*;
import java.io.*;
import java.net.*;
import java.util.StringTokenizer;
public class FileComparer
public static void main (String[] args)
String line, file="http://condor.depaul.edu/~jpetlick/extra/224/display.txt";
String line2, file2="http://condor.depaul.edu/~jpetlick/extra/224/display2.txt";
int lineCount = 0, wordCount = 0, lineCounter = 0;
try
URL URLfile = new URL (file);
InputStream input = URLfile.openStream();
BufferedReader buffer = new BufferedReader(new InputStreamReader(input));
line = buffer.readLine();
URL URLfile2 = new URL (file2);
InputStream input2 = URLfile2.openStream();
BufferedReader buffer2 = new BufferedReader(new InputStreamReader(input2));
line2 = buffer2.readLine();
while (line != null)
if (line != line2)
System.out.println("at Line " + lineCounter);
System.out.println("DISPLAY.TXT " + line);
System.out.println("DISPLAY2.TXT " + line2);
lineCounter++;
StringTokenizer st = new StringTokenizer(line);
wordCount += st.countTokens();
lineCount++;
line = buffer.readLine();
line2 = buffer2.readLine();
System.out.println("\nA total of " + lineCounter + " were different between DISPLAY.TXT and DISPLAY2.TXT");
System.out.println("DISPLAY.TXT contains:");
System.out.println("\nTotal number of lines: " + lineCount);
System.out.println("Total number of words: " + wordCount);
catch (FileNotFoundException exception)
System.out.println("The file " + file + " was not found.");
catch (IOException exception)
System.out.println(exception);
}

A quick glance at your code tells me that you are using the wrong operator to compare two strings.
== and != will compare the two OBJECTS, and find them to be not the same object.
Try
if (!line.equals(line2))
You might also explore - depending on the requirments:
if (!line.equalsIgnorCase(line2))

Similar Messages

  • Thin white line between line art and live paint fill?

    I am using live paint to paint cartoon character illustrations.  The artwork is brought into Illustrator CS3 and live traced.  Then I convert it to a live paint group and use the paint bucket to fill.  Everything looks fine no matter how much I zoom in.  If I bring the AI file into Photoshop CS6 I can see a thin white line between the black line art and the fill.  This is most noticeable where black meets black. I can also see this sometimes in file previews while browsing through files.  If the white line cannot be seen in Illustrator is the file ok?  I did just upgrade to CS6 if that would make a difference.
    Thank you for any help.    

    If the white line cannot be seen in Illustrator is the file ok?
    Without knowing specifics,nobody knows.
    "Okay" for what?
    If it looks okay to you in Illustrator, then it's okay for viewing in Illustrator.
    If the export of it does not look okay in Photoshop at 1:1 or higher zoom, then it's probably not okay for whatever you're going to do with that raster image.
    If it's printed to a low-res composite printer, then it may be okay, because the printer may not be able to resolve the whitish pixels.
    If it's printed for commercial (color-separated) reproduction, it may not be okay, depending on the scale at which it will be printed, and on other considerations partially described below.
    The autotrace routine does not build traps. Typically, when you color-fill cartoon line art manually, you don't make the shapes that define the fills merely "kiss" the black line work, as would the default treatments of a stupid autotrace. The black line work typically overprints the fills, thereby creating printing traps.
    Suppose a portion of your cartoon is a hand-drawn closed circle. The black line work is irregular; it varies in width, having been drawn with a marker or a brush. The circle is colored in with a medium green. There are no sloppy gaps in the original between the green and the black.
    You scan it and autotrace it. Unless you apply some deliberate care to make it do otherwise, the autotrace is going to create a compound path, filled with black, and with no stroke; and a green simple path which (hopefully) exactly "kisses" (abuts) the black path. Adobe's on-screen antialiasing of the edge where the two colors abut may or may not cause your monitor to display a faint whitish or grayish sliver between the two colors.
    Similarly, Photoshop's rasterization of it, or the rasterization of a raster export filter may do the same, and may actually result in some off-color pixels along the edge. (Your description of the scenario kinda raises the question of why you are auto-tracing something that you're then just going to rasterize in Photoshop anyway. Why do that? Why not just work with the scan in Photoshop?.)
    So let's leave Photoshop out of the picture and assume you are autotracing it because you want vector artwork. You zoom way in to see if the whitish sliver enlarges. It doesn't, so you assume it's just an aberation of Illustrator's on-screen antialising. And then someone tells you you're in the clear. But are you? Not so fast.
    Let's assume the artwork is destined for commercial (color-separated) printing. Further assume the color of the autotraced black is 100% K, and the color of the autotraced green is 100Y 50C. Three inks involved. None of those three inks are shared between the two objects. So even if the paths do, in fact, perfectly abut, there is no "wiggle room" built in for the minor alignment shifts that almost aways do occur on press.
    Bottom line: Even if you do determine that the common antialiasing aberations that frequently occur on-screen in Adobe apps is just that—just an onscreen aberation, that does not necessarily mean your file is suitable for commercial color-separated reproduction.
    First, you need to understand that autotracing is not the one-click, instant "conversion" of a raster image to vector artwork that far too many think it to be. Just like everything else, you don't just launch a program like Illustrator, start autotracing things willy-nilly without understanding what's really going on. Just like anyting else, you can use an autotrace feature intelligently or...well...not.
    You have options. Illustrator provides an auto-trapping feature. Read up on it in the documentation so you understand what it's all about. Alternatively, you can expand the results of your autotrace, select all the black linework and apply a composite color that includes 100% K and reasonable percentages of C, M, and Y (a so-called "rich black"). Or,depending on the artwork and the desired results, you may consider doing the autotrace as centerlines so you have stroked paths, not just filled paths for the linework. That way, using the flood fill (so called LivePaint) will cause the auto-created fill objects to extend to the paths, not just to the edges of their strokes. Then set the linework to overprint.
    At any rate, if you are doing this professionally, you need to read up on the principles and practices of trapping and color separation.
    JET

  • One line between all the sentences

    Hi all
    I have a text file which has many sentences and there are number of newlines between these sentences are they are not unique some times they are 3 or 5 or 1
    How can I make all the space just one??
    i.e
    I went to the park
    I had 3 sisters
    He is playing with his friend each Sunday
    To be:
    I went to the park
    I had 3 sisters
    He is playing with his friend each Sunday

    Read the file skipping blank lines and storing the sentences in some type of array. Write the sentences back out, adding one blank line between each one.
    Do you have any more specific questions about parts of that?

  • Database Firewall in-line between clients and database not working

    I’m trying to configure a Standalone Database Firewall in-line between the clients and the protected database so it can block some statements. I’ve followed the Installation Guide and the Administration Guide, but can’t get it working. I’ve configured one Enforcement Point with one Protected Database.
    I’ve configured Database Firewall with three Ethernet cards:
    eth0 is used for Management (IP. 192.168.1.81)
    eth1 and eth2 are associated with Bridged interface br0
    The protected database is listening in 172.16.40.3:1521.
    The clients are in subnet 192.168.1.x.
    I’ve configured the Traffic Source br0 with the IP 172.16.40.2 and is enabled as the Traffic Source in the Enforcement Point.
    In the configuration file appliance.conf corresponding to the Enforcement Point, I’ve seen the parameter PROXYPORT=1534, so I understand the clients should connect to this port in Database Firewall in order to access the protected database. Is this assumption correct? Is the configuration I’ve done correct? Are there any additional configuration steps that should be made? Is there any documentation about this configuration files?
    Thanks,
    Pablo

    For in-line blocking mode to work out of the box it is necessary that DB Client's IPs (as they are seen in DBFW), br0 and DB IP are all on the same subnet. If this is not the case you would need to fiddle with routing on the DBFW manually which you are discouraged to do because it's unlikely to be persistent, work correctly after upgrades etc... DBFW is not intended to be a router although it can be made to perform this function. In general I would advise you to stay within the supported configuration and just make sure you network infrastructure is ready for DBFW deployment. IE make sure all these IPs are on the same subnet

  • Draw line between black pixel : coordinates of selected pixels ?

    Hi
    I want to build a script which can check a Photoshop file and :
    - find black pixel
    - for each black pixel, look for another black pixel within maximum distance of 5 pixels
    - then draw a line between the two black pixels.
    I wrote this script below (my first script ...), but it's VERY slow (and my final image is VERY big), I think because I test the colour for each pixel of the image.
    So another solution would be to first select black pixel with magic wand, then the script save all coordinates of selected pixels, then my script wil test only this pixels (less than 1% of the pixels are black in my image).
    Is it possible with JavaScript ?
    Thank you for your response !
    Marc
    function main(){
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var myHeight = app.activeDocument.height;
    var myWidth = app.activeDocument.width;
    // Find black pixel
    for(var i=5; i<myWidth; i++) {
      for(var j=5; j<myHeight; j++) {
       activeDocument.colorSamplers.removeAll()
       var sampler = activeDocument.colorSamplers.add([new UnitValue (i, 'px'), new UnitValue (j, 'px')]);
       if (sampler.color.rgb.hexValue === "000000") {
    // For each black pixel, search another black pixel below left up to 5 pixels
        for (var m=i-5; m<i; m++) {
         for (var n=j+1; n<j+5; n++) {
          activeDocument.colorSamplers.removeAll()
          var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
          if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
           var FillColour = new SolidColor;
           FillColour.rgb.hexValue = '000000';
           var ad=activeDocument;
           ad.selection.select([[m,n],[i,j],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
           ad.selection.fill(FillColour);
           ad.selection.deselect()
    // For each black pixel, search another black pixel below right up to 5 pixels
         for (var m=i+1; m<i+5; m++) {
          for (var n=j; n<j+5; n++) {
           activeDocument.colorSamplers.removeAll()
           var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
           if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
            var FillColour = new SolidColor;
            FillColour.rgb.hexValue = '000000';
            var ad=activeDocument;
            ad.selection.select([[i,j],[m,n],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
            ad.selection.fill(FillColour);
            ad.selection.deselect()
    main();

    The first alert should have shown the first pathPoint.anchors for all the subPaths in the path.
    The xyArray is just something I added for the alerts. The array 'myPathInfo' should have all the info extracted from the path.
    myPathInfo.length will tell you how many subPaths are in the Path.
    myPathInfo[index].entireSubPath.length will tell you how many pathPoints are in that subPath
    myPathInfo[index].entireSubPath[index].anchor will tell you the position of that pathPoint.
    The indexes start with zero.
    The bounding box of the entire subPath can be hard to work out just from the pathPoints. Unless all the point are corner points the path may extend beyond the anchors. One think you can do is create a new path from just one of the subPaths, convert by to a selection, and then get the bounds from the selection. You can make a new path from a subPath using the 'myPathInfo' array from above.
    app.activeDocument.pathItems.add("myPath1", [myPathInfo[0]]);
    That line will make a new path from the first subPath. Change the index to use a different subPath.
    Some other info that may help.
    app.activeDocument.histogram[0] will tell you how may black pixels are in the document. But its no help determining where they are. If that returns 0 there are no black pixels.
    If you don't have any luck working with converting the original color range selection into a path and need to go back to searching with the colorSampler it may help to use a grid approach. For example make a square selection, the size depending on how scattered the black pixels are, say 25x25px. Then use color range to select black. With an active selection it will only select pixels in that selected area( if any). You could then check to see if there is a selection. If not make another same size square to the right edge of the last area. If there is a selection, the solid property will tell you if more than one black pixel was selected( unless they are right next to each other ). If solid == true the selection bounds will tell you where the pixel is. If false you have to then search that square. But if there are areas where there are no black pixels checking a square range of pixels at once should be quite a bit faster than checking every pixel. And checking the historgram first will let you know if you should bother searching to start with.

  • How to add separating line between facing pages when exporting to PDF

    Hello,
    I've searched a lot and could not find an answer to my question...
    I'm creating several multi-page documents with facing (left-right) pages. After that I export these to PDF. I use the same setting for all my files and same settings for exporting.
    But one of the documents when exported doesn't have a separating line between the left and right pages and they seem to be one. How can I add this separating line?
    Thanks in advance!

    Hi Peter, thanks you for your reply. If I understand correctly what you are saying, I would say this is not the case, because both are exported as spreads and both are displayed 1-up. Please see attached screenshots - first two show exporting options and second two show how it will look in Acrobat if both are displayed 2-up.

  • Pattern brush, colored lines between segments

    Hi all,
    Issues with the pattern brush won´t stop for me...
    This time I try to create a pattern brush from paths, everything seems aligned to be but still there are discoloured lines between the segments. I´ve tried again and again and now I´m tired of it. Everytime I read a tut it seems simple but I can´t get it to work. Here is a link to the Ai file I´m using ( CC ), perhaps someone can have a look and point me to the obvious. Those gaps stay after export, so it´s not a preview thing I guess.
    Thank you in advance,
    IOError

    Did not thought of that. Thank you very much. I think I´ll read your book

  • Horizontal separator line between masthead and tool area

    hi all
    we have customized the portal masthead with our own background image and all.
    however the masthead looks fine in IE but in Mozilla it puts a white horizontal line between the masthead and tool area and since our tool area background is not white it looks wierd.
    any ideas how i can fix that.
    thanks

    Rather than use one of the selection tools, try selecting the object with a mask. With the mask you can hide by painting with a black brush, reveal (and correct) with a white brush. I use PSEv.8, so I have to hijack the mask from an adjustment layer, but your version of the program has a mask buit in.
    Here is a stock photo of a brick wall for demonstration
    http://www.pixentral.com/show.php?picture=1bPkncRl9f24RslkWKdP0NyaYIt9N1
    Try this:
    Open you picture file
    Duplicate the background layer
    Convert the background copy layer to black/white
    Apply the mask. Left click on the mask
    Paint with a black brush where you want to reveal the color. If you go too far, correct with a white brush

  • Lines Between Report Columns in Purchase Order Report

    Hello All,
    I am working with the Oracle Purchasing Report called POXPRPOP.rdf. I am trying to add a black frame between each column in the report. Imagine in a purchase order where several columns of data that have a black line in between them. I have tried working with the expanding frame around the data fields of the report, changing the line color of these expanding frames to black. This didn’t work to give me lines in between the columns. I have been able to bring other graphical elements into the report so it is not a graphics problem at the UNIX environment.
    I am using Reports 6i and Running the report through Oracle Applications Concurrent manager.
    Thanks for any help,
    Bradley

    It seems like I might be able to put a line between the data fields and set it to expand with the repeating frame. Maybe this is this how it is done.
    Bradley

  • How do i plot with the operating system time in one plot and show lines between cursors in another using the same XY graph?

    I am having some trouble graphing two plots at once. One plot is to show the current temperature inside a chamber as a function of time. I am trying to pick the current time and temperature each second and plot it with each point being connected by a line. I am able to show a moving, blinking dot each second but I can't figure out how to develop an actual line with these dots. To make matters worse, the blinking dot is back in the year 1903. I understand that it uses seconds elapsed since 1903, and am trying to find out how to graph the current temperature with the system time.
    The second plot is just 5 moveable cursors that are to be connected by a line. I am able to move the cursors and retrieve the position information, but I can't make a line between them.
    I have attached my main .vi, though you may have to pick the graphing part off to have it work for you.
    Attachments:
    Main Module Chamber Testing I_O every 30 sec.vi ‏288 KB

    You're not creating the XY graph data correctly. I've attached an example with a couple of simple XY Graphs. One is using a couple of shift registers to hold the spearate x and y arrays. I think this is what you were trying to do. The other one uses a VI from the shipping examples called XY Chart. It makes an XY Grpah act like a chart. I've also shown the correct way to display current time.Message Edited by Dennis Knutson on 05-12-2005 03:51 PM
    Attachments:
    XY Graph.vi ‏41 KB

  • How to delete the specified line in file?

    How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?

    An alternative solution can be :
    import java.io.LineNumberReader;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    public class LineDeleter {
    public static void main(String args[]){
    try {
    //suppose you want to delete line 3
         int lineToBeDeleted = 3;
         File f = new File("line.txt");
         long fileSize = f.length();
    //Wrap the FileReader with a LineNumberReader. It will help you
    //identify the lines.
    LineNumberReader lnr = new LineNumberReader( new FileReader(f));
    //Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
    //equal to the file size.
         BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
    //Wrap BufferedWriter object with PrintWriter so that it allows you
    //to print line by line
    PrintWriter pw = new PrintWriter(bw);
         String s=null;
         while ( (s=lnr.readLine())!=null ){
              System.out.println(s);
              int lineNumber = lnr.getLineNumber();
    //match the line number
              if(! (lineNumber==lineToBeDeleted)){
                   pw.println(s);
              pw.flush();
              lnr.close();
              pw.close();
         catch(Exception e){System.out.println(e);}
    If you want you can rename the line1.txt to the original file name.
    I hope this helps.Good luck!!!!!!

  • How can i traverse between files in a directory

    how can i traverse between files in a directory. I ahve seen in the site that isFile can be used to switch from one file to other but i didn't found such method. I am working in Eclipse. I would be thankful if u send me the solution.I mean the way to traverse

    listFiles() returns all the files in a directory. You can check if it is a file and read it. Read the API docs.
    If you have specific problem with your code, post the code and the problem description.

  • It possible to insert lines between 2 other lines in Grid

    Hi
    Is it possible to insert lines between 2 other lines in the Grid. Example, I need to enter a new item between line 1 and 2 in the grid. Similar to inserting lines on the sales documents.
    Can any having any idea please share with me.
    Regards
    Senthil

    Hi,
    have a look at the DataColumns Collection
    A collection of DataColumn objects. Use this collection to add columns to the collection or remove columns from the collection.
    You can access the collection via the DataTable.Columns property.
    you'll find it in the UI API Dokumentation.
    i hope it helps you.
    regards
    David

  • How to hide the grid lines between two rows in a ALv? Please help!

    Hi Experts,
             I have a ABAP ALV(reuse alv grid FM) report.
    The last field in the ALV is "Description" which can contain data of size more than 130 chars.
    Since the max field length in ALV grid is 130 chars hence I am splitting this field value whenever the field length is more than 130 chars.
    After splitting I am generating duplicate rows but with different "Description" field values ( each contains the splitted values".
    For example:
    Name| City | Description                             |
    Hari|HK    |Employee responsible for time management |
    Hari|HK    |and issue resolution                     |
    Now I want to hide the grid line between these two rows
    and just for Description field.
    In other words I want ALV to display like this:
    Name| City | Description                             |
    Hari|HK    |Employee responsible for time management |
    Hari|HK    |and issue resolution                     |
    How can I acheive this?
    Please provide some sample code.
    Please help. I will be really greatfull to your help.
    Thanks
    Gopal

    Hi Rich,
          If that is the case then atleast how can I hide the complete row grid line?
    Please give some sample code.
    Thanks
    Gopal

  • No blank line between address node in smartform

    hi all ,
    customer want to delete the blank line between address , is there a way to solve this ? i just want to use the address node.
    regards
    Kevin

    For the paragraph format used with the ADDRESS command, indicate that you don't want blank lines.
    Eg.    /: ADDRESS PARAGRAPH ZD
    So for this Paragraph Format 'ZD'  check the checkbox 'No Blank Lines'.

Maybe you are looking for

  • Purchase Order Cancellation/Deletion

    Dear SAP Gurus, I would appreciate if any of you could advise me the best way to handle the below specific scenario. A PO is created based on a PR. It has been released an approved. No GR/IR has been created. How do I cancel this PO (regardless wheth

  • Displaying ABAP report on a web browser

    Hi,   I want to develop a code for displaying ABAP report on a web browser.

  • Help with Java JAR file opbfuscation.

    I am looking for a free (no $) for use on commercial java code code obfuscation program, which can beat the Jode decompiler. I have tried Proguard, and I have tried Joga (using Jode itself for obfuscation is too complex for my purposes). Is there a s

  • Content Aware on Panorama

    I was very excited to see the content-aware sneak peek video, where Photoshop automatically filled in the edges of the panorama photo by just selecting the empty space. I was very anxious to give it a go, but was disappointed with the results, or lac

  • IDL help, lost at NamingContext

    I have been reading the specialized trail on Java IDL. So far most of it are falling into place for me, but the tutorial had me at: Obtaining the Initial Naming Context The first step in using the naming service is to get the initial naming context.