How to realize single line in eclipse's file compare tool

You may use the eclipse's file compare tool, when it compare two files it display two files side by side, and connect ranges with single line. When you scroll the pane, these single lines with change their forms accrodingly but always connect ranges.
I'm programming a similar tool to the eclipse's file compare tool. I'd like to know which classes are related to this kind of "single line", any suggestion will be appreciated.
Best regards

Thank you very much for your reply.
In fact I am not sure what I am planning to do. If it is too complicated, I will modify the design and make it easier to realize. Cause I don't know any classe for drawing lines, do you know any more besides java.awt.geom.Line2D?
In addition, I posted another message related to this one. They are different parts of one same project, can you take a look at it?
Thank you very much.

Similar Messages

  • Change of a single line in a text file

    Is there a option in CVI to change a single line in a text file (.txt), without reading the whole text file into the buffer and writing the whole buffer back after the editing from the one line?

    Not that I am aware of.
    I'll be glad to know such a function if somebody can point us to it! 
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to write single line text file

    Hi, I need to write a single line text file using oracle forms 10g that's usually quite long 8million+ characters, I looked into utl_file but came accross the single line limit, is there any way to do this either to the client pc or to the server
    Thanks

    I tried using put_line but i get a ORA-29285: file write error´I´m guessing this is because of the amount of data to be written on a single line

  • How to insert new line in a text file

    hi all,
    i wnat to know how can i insert a new line in a text file using java.
    for example i want the formate of the text like this
    1 2 3
    4 5 6
    until now i know only how to insert data but not new line.
    Thanks in advandce

    Hi you can put a new line in a text file using System.getProperty("line.separator"). This implementation will work for every OS.
    import java.io.*;
    class Demo{
    public static void main(String args[]) throws Exception {
    FileWriter fr = new FileWriter("FileDemo.txt");
         fr.write("AAAAAAAAAA");
    fr.write(System.getProperty("line.separator"));
    fr.write("AAAAAAAAAAA");
    fr.close();
    }

  • How to read every line from a text file???

    How can i read every line from my text file ("eka.txt")
    now it only reads the first line and prints it out.
    What is wrong with this?
    import java.io.*;
    import java.util.*;
    class Testi{
         public static void main(String []args)throws IOException {
         BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
    File inputFile = new File ("eka.txt");
    FileReader fis =new FileReader(inputFile);
    BufferedReader bis = new BufferedReader(fis);
    String test=bis.readLine();
    String tmp= "";
    while((bis.readLine().trim() != null)) {
    int spacefound=0;
    int l=test.indexOf(" ");
         for(int i=0;i<test.length();i++){
         char c=test.charAt(i);
         if(c!=' ') tmp+=""+c;
         if(c==' ' && (spacefound<1) && !(tmp.equals(""))){
         tmp+=""+c;
         spacefound++;
         if(tmp.length()==l) {
         System.out.println(tmp);
         tmp="";
         spacefound=0;
         if(tmp.length()<l){
         for(int i=0;i<=(l-tmp.length());i++)
         tmp+=""+' ';
         System.out.println(tmp);

    Try this code, Hope it servers your purpose.
    import java.io.*;
    import java.util.*;
    class Testi {
         public static void main(String []args)throws IOException {
              BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
              File inputFile = new File ("Eka.txt");
              FileReader fis =new FileReader(inputFile);
              BufferedReader bis = new BufferedReader(fis);
              String test=bis.readLine();
              while(test != null) {
                   StringTokenizer st = new StringTokenizer(test," ");
                   while(st.hasMoreTokens())
                        System.out.println(st.nextToken());
                   test = bis.readLine();
    }Sudha

  • How to read some lines from a text file using java.

    hi,
    i m new to java and i want to read some lines from a text file based on some string occurrence in the file. This file to be read in steps.
    we only want to read the file upto the first Occurrence of "TEXT" string.
    How to do it ,,,
    Kinldy give the code
    Regards,
    Sagar
    this is the text file
    dfgjdjj
    sfjhjkd
    ghjkdg
    hjkdgh TEXT
    ikeyt
    ujt
    jk
    tyk TEXT
    rukl
    r

    Hendawy wrote:
    Since the word "TEXT" is formed of 4 letters, you would read the text file 4 bytes by four bytes. Wrong on two counts. First, the file may not be encoded 1 byte per character. It could be utf-16 in which case it would be two byte per character. Second, even if it were 1 byte per character, the string "Text" may not start on a 4 byte boundary.
    Consider a FileInputStream object "fis" that points to your text file. use fis.read(byte[] array, int offset, int len) to read every four bytes. Convert the "TEXT" String into a byte array "TEXT".getBytes(), and yous the Arrays class to compare the equality of the read bytes with your "TEXT".getBytes()Wrong since it relies on my second point and will fail when fis.read(byte[] array, int offset, int len) does not read 4 bytes (as is no guaranteed to). Check the Javadoc. Also, the file may not be encoded with the default character encoding.
    The problem is easily solved by reading a line at a time using a BufferedReader wrapping an InputStreamReader wrapping a FileInputStream and specifying the correct character encoding.
    Edited by: sabre150 on Apr 29, 2009 2:13 PM

  • How to make cursor lines appear in saved file

    I have a graph that has 3 cursor lines.  They are visible on the graph.
    When saving the graph to a file (.png or .jpg) the graph waveform is visible, but the cursor lines are not.
    The image data does not contain the cursor lines.  How do I include those to the image data.
    I verified the image data using an image indicator and the appropriate VI..  So for some reason, the image that is being saved is of the indicator (Waveform Graph) and the waveform (data), but not the cursor lines. 
    I'm sure I've saved images of a graph that included the cursor lines in the past (LV7.x), but I cannot remember what I did. 
    Thanks,
    RayR

    Thanks Christian,
    I (may) have found the problem...  At one point, I clear all cursor lines.  I may have a race condition between clearing the lines & saving image to file.
    I did see the cursor lines in one instances when I stopped the program prematurely. 
    I knew it had to be siomple.  I didn;'t recall doing something special the last time I did this..
    Thanks!
    RayR

  • How to read last line from a .txt file?

    Hello
    I have a string: e.g. "my name is John"
    and i wanna verify if this string is equal with the last line from a text file
    for example, if in the txt file i have:
    asdasd
    sdgsdfgasd
    asdfgadfgadf
    sdgasdgsdf
    my name is john
    then it's OK.
    but if i have
    asdgsdfg
    dsfhsdfhsd
    sdgasdfg
    sdgsdg
    my name is Jdfgsdg
    this is not correct
    How should i do this?
    Thanks:)

    Read from the beginning an discard all lines (if you have a small file), or use RandomAccessFile and scan from the end till you find the beginning of the last line.
    Kaj

  • How to write new line character to a file from textarea

    Hi ,
    I want to save the contents of textarea in a file.The textarea may contain new line characters,
    I am getting the contents from the textarea using getText() method but after writing the contents to the file
    it stores the entire text in a single line.But I want the text as it apperars in the textarea.
    Please provide me a good solution.
    -mani

    maybe this code samples are useful to your problem
    File datatext = new File(fileName);
    try {BufferedWriter writer =new BufferedWriter(new OutputStreamWriter(new FileOutputStream(datatext)));
    writer.write(.......);
    writer.newLine();
    writer.close();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to recognize empty lines in a source file

    Hi to all
    I want to count he empty lines in a source file. I've been using the methods provided by String such as "contains" ecc but for example
    String line = new String();
    line.startsWith(\r); in order to trace the carrage return in order to consider this as an empty line didn't work
    I cut and paste here my code any hint is apreciable!
    import java.io.*;
    public class Filereader {
    public Filereader() {
    public static void main(String argv[]) {
    File temp = new File("LOC.txt");
    File list = new File("mylist.txt");
    String line = new String();
    String lineinternal = new String();
    int linecounter = 0;
    int sourcelines = 0;
    int commentlines = 0;
    int complexlines = 0;
    boolean commentflag = false;
    try {
    FileReader fileinput = new FileReader(list);
    BufferedReader buffinput = new BufferedReader(fileinput);
    FileWriter fileout = new FileWriter(temp);
    BufferedWriter out = new BufferedWriter(fileout);
    out.append("NOME");
    out.append(" \t");
    out.append("LOC");
    out.append(" \t");
    out.append("LCom");
    out.append(" \t");
    out.append("Ltot");
    out.newLine();
    boolean eof = false;
    boolean eofinternal;
    while ( !eof ) {
    eofinternal = false;
    line = buffinput.readLine();
    if ( line != null ) {
    linecounter = 0;
    sourcelines = 0;
    commentlines = 0;
    complexlines = 0;
    FileReader fileinternal = new FileReader(line);
    BufferedReader buffinternal = new BufferedReader(fileinternal);
    while ( !eofinternal ) {
    lineinternal = buffinternal.readLine();
    if ( lineinternal != null ) {
    linecounter++;
    if ( lineinternal.contains("//") && (!commentflag) )
    commentlines++;
    if ( lineinternal.contains("/*") )
    commentflag = true;
    if ( commentflag )
    commentlines++;
    if ( lineinternal.contains("*/") )
    commentflag = false;
    if ( !commentflag ) {
    if ( (lineinternal.contains(";")) && (lineinternal.contains("//")) && (!lineinternal.startsWith("//")) )
    complexlines++;
    else
    if ( (lineinternal.contains(";")) && (lineinternal.contains("/*")) && (!lineinternal.startsWith("/*")) )
    complexlines++;
    else
    if ( (lineinternal.contains(")")) && (lineinternal.contains("//")) && (!lineinternal.startsWith("//")) )
    complexlines++;
    else
    if ( (lineinternal.contains(")")) && (lineinternal.contains("/*")) && (!lineinternal.startsWith("/*")) )
    complexlines++;
    else
    if ( (lineinternal.contains("}")) && (lineinternal.contains("//")) && (!lineinternal.startsWith("//")) )
    complexlines++;
    else
    if ( (lineinternal.contains("}")) && (lineinternal.contains("/*")) && (!lineinternal.startsWith("/*")) )
    complexlines++;
    else
    eofinternal = true;
    buffinternal.close();
    sourcelines = (linecounter - commentlines) + complexlines;
    Integer data1 = new Integer(sourcelines);
    Integer data2 = new Integer(commentlines);
    Integer data3 = new Integer(linecounter);
    String f = data1.toString();
    out.append(line);
    out.append(" \t");
    out.append(data1.toString());
    out.append(" \t");
    out.append(data2.toString());
    out.append(" \t");
    out.append(data3.toString());
    out.newLine();
    else {
    eof = true;
    buffinput.close();
    out.close();
    System.out.println("...end of try catch ");
    catch (IOException e) {
    System.out.println("Error..." + e.toString());
    catch (Exception e) {
    System.out.println("Error..." + e.toString());
    Thanks in advance to all
    Mandy

    Try this:
    String trimmedLine = lineFromFile.trim();
    if ("".equals(trimmedLine))
        // logic for trimmed line
    }That's some ugly procedural code. Long "if/else if/else" is a very bad sign.
    I'd advise that you at least move this mess out of main() and into a method that you could just call. I don't know if this will be reusable or not, but you won't have a chance of it being callable in another context if you leave it all in main().
    %

  • How to get the line number of source file?

    Hi,
    What is the equivalent in Java of the __LINE__ and __FILE__ macros in C? I want to print out the line number and the file name where the instruction is being executed.
    Thanks,

    If you are doing this because you're implementing your own debug logging, have a look at Log4J.
    You can configure it to log classnames, method names and line numbers of the code you're executing.

  • How to customizing single line comment

    Because of the restriction of our dsl language we cannot use SL_COMMENT terminal directly. We have own rule of "Comment" which is defined as a parser rule.
    // '..' is the identifier of our comment rule just like '//'
    Comment:
    '.' '.' (ID|INT|ANY_OTHER)*
    Now we have a problem:
    How can we insert/remove '..' with standard shortcut "Ctrl+/" ? Could we reimplement this feature anywhere in XText ?
    Has anybody any idea for it?

    Christian Dietrich wrote on Tue, 30 June 2015 12:32org.eclipse.xtext.ui.editor.toggleComments.ISingleLineCommentHelper.getDefaultPrefixes(ISourceViewer, String)
    Thanks for your useful hints. It helps me so much.
    But still a problem could not be solved. We have following grammar:
    // this is not comment
    ..!meta foo bar
    //following 2 line are comments
    ..!foo bar
    ..foo bar
    It means that every line which begins with '..' is a comment except that begins with '..!meta'.
    Now the problem is:
    When I type 'ctrl+/' at line '..!meta foo bar', it removes the prefix '..'. But I want to insert '..' before '..!meta'.
    How can I do it? Should I reimplement ToggleSLCommentAction? If yes, where is this Action called or injected?

  • How to handle long lines in a JAD file?

    Hi all,
    setting MIDlet permissions in a JAD file easily expands the length of one line so that they need to get wrapped into 2 or more lines. AFAIK JADs actually are manifest files and the manifest file spec says that a line continuation is marked by a line beginning with a single space. I use Ant to create the JAD file and Ant's manifest task does it exactly like this. Example:
    MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client,j
    avax.microedition.io.Connector.socketThis works on my Sony Ericsson phone and in the MicroEmu emulator, but the WTK (2.5.2) emulator complains about that by throwing an exception:
    com.sun.midp.midletsuite.InvalidJadException: Reason = 28
         at com.sun.midp.midletsuite.JadProperties.partialLoad(+259)
         at com.sun.midp.midletsuite.JadProperties.load(+8)
         at com.sun.midp.dev.DevMIDletSuiteImpl.create(+252)
         at com.sun.midp.dev.DevMIDletSuiteImpl.create(+74)
         at com.sun.midp.main.Main.runLocalClass(+20)
         at com.sun.midp.main.Main.main(+80)So who is wrong here?
    Thanks for some information!
    Best regards,
    Brian

    MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client,j
    avax.microedition.io.Connector.socketif memory serves, inability to handle stuff like above is a known WTK bug.
    Try workarounds like "glueing" permissions into single (long) line or splitting them on commas

  • How to skip certain lines for a txt file and insert into array

    so here is my question:
    i had a file to read, and it requires to input into the array starting from a certain line
    example:
    4
    john 25 M
    mary 22 F
    lee 20 M
    faye 10 F
    faye john
    mary john
    mary faye
    i want to insert the friend list, starting 5th line into a 2d array, which is the int from first line +1.
    can someone help me with it?
    i believe there is a skip method and stuff..
    but just dont know how to use it
    may someone tell me how to do tat?

    the thing is i think that takes too long and it is not efficient..
    however...i just solved it with a better method
    Scanner in = new Scanner (reader);
    int size = Integer.parseInt(in.next());
    BufferedReader insert = new BufferedReader(new FileReader(new File(input)));
    String line = null;
    int count = 0;
    int startAtLineNo =size+1; // 0-based
    while ((line = insert.readLine()) != null) {
    if (count >= startAtLineNo) {
    /* do stuff */
    System.out.println(line);
    // else ignore
    count++;
    thanks anyways

  • How to read partcicular line from a txt file

    in a text file let there be 50 lines
    while reading the line if the line is having "name" as a string in that line then i have to store the next two consecutive lines in a string as array....
    Similar way and so on......
    How can we do this....

    You need a BufferedReader:
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html
    for example:try {
        BufferedReader br = new BufferedReader(new FileReader("myfile.txt"));
        String line;
        while ( (line=br.readLine()) != null ) {
         if (line.indexOf("name") != -1) {
             // Store the next two lines.
             // You will need to call br.readLine() again.
    } catch (IOException x) {
        x.printStackTrace();
    }

Maybe you are looking for