Search for a blank line

how can i search for a blank line thru a java program??

how can i search for a blank line thru a java
program??You can use following code:
BufferedReader reader = null;
try{
File file = new File("C:/temp/abc.txt");
FileReader reader = new FileReader(file);
BufferedReader reader = new BufferedReader(reader);
String line = null;
while( (line = reader.readLine()) != null ){
if(line.trim().length() == 0){
//Code for handling the blank line.
} else {
//Code for handling the line with content.
} catch(IOExcepttion ioe) {
ioe.printStackTrace();
} finally{
if(reader != null){
try {
reader.close();
}catch(IOException io){
System.out.println("Error occured while closing Reader");

Similar Messages

  • My group box is causing problems when searching for a text line in a text file.

    I am developing a booking system, so for this I need to ensure that no two clients can book the same appointment slot. So, on testing my code which prevents double booking, the system doesn't seem to find the text line being searched for in the text file
    when it (purposefully) should.
    I have tried isolating the problem using breakpoints, and I've found that when the 'SearchLine' (referring to my code below) does not include the 'TimeComboBox.text' piece and instead this value is written into the code, the system is able to find the SearchLine
    without any problems. But, when assigning the group box's value to a variable and using this in the SearchLine instead, or without even using a loop and just doing a simple line by line search, the program can't find this line of text in the file.
    I'm lost for ideas. I have tried everything I can think of. Could anyone make any suggestions as for what is the problem with my group box? (I'll explain the code beneath it).
    'Setting the value of the SearchLine (which is a String)
    SearchLine = String.Concat(DateTimePicker1.Value.Date & " " & TimeComboBox.text)
    Dim FoundApp As Boolean
    Dim objReader As New System.IO.StreamReader(basicfilepath & "Text Files\Client Booked Appointment DatesTimes.txt")
    FoundApp = False
    'Reading the file's contents and checking for the SearchLine
    Do While (objReader.Peek() <> -1) or (FoundApp = True)
    If (TextLine = SearchLine) Then
    'Line contains SearchLine. Appointment already exists.
    FoundApp = True
    Else
    'Line doesn't contain SearchLine. Carry on searching.
    Msgbox("Line not found.")
    End if
    Loop
    Explanation
    When the line is searched for, the 'FoundApp' value must be set to 'True' when it is found. If it is not found, it remains false.
    To isolate the problem, I've displayed the SearchLine in a message box in the past to make sure that the correct line of text is being searched for.
    In basic terms, my program is searching for the exact line of text which exists in the text file, but for some reason it is not coming up as 'Found'. The error occurs when the group box's value is used. The text file which is being read is
    definitely correct. Please help, any suggestions would be appreciated.
    Thank you

    Hi
    It would appear that your snippet doesn't actually read the file at all.
    Here is my test which works fine.
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim SearchLine As String = "18:09:38 : XTaskSettings.Load PARAMS: begin"
    Dim FoundApp As Boolean = False
    Dim TextLine As String = Nothing
    Dim objReader As New IO.StreamReader(Application.StartupPath & "\Data\Report Q1.txt")
    FoundApp = False
    Do While (objReader.Peek() <> -1) Or (FoundApp = True)
    ' this was missing
    TextLine = objReader.ReadLine
    If (TextLine = SearchLine) Then
    'Line contains SearchLine. Appointment already exists.
    FoundApp = True
    MsgBox("Line found.")
    Else
    'Line doesn't contain SearchLine. Carry on searching.
    MsgBox("Line not found.")
    End If
    Loop
    End Sub
    End Class
    Regards Les, Livingston, Scotland

  • Parallelized for loop. Searching for a one-line solution

    Hi.
    In an usual day I do a lot of for loops inside of command line. But I noted that my loops don't use the full power of my dual core processor, they only use one processor.
    A lot of the loops I do have independent interactions in the sense that a interaction code don't need the results of another interaction. This is the simplest problem in multiprocessing, I only need to execute N process in parallel.
    I'm searching for a one-line solution that I can use in place of a 'for i in *.txt; do echo $i;done'. With one-line I means that can be used as one-line but the implementation can be longer. And can be in any programming language.
    For now I'm using the following small python solution (the smallest I could get)
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    from multiprocessing import Pool
    from glob import glob
    from subprocess import call
    def f(x):
    call(['asy', '-f', 'png', '-render=0', x])
    pool = Pool(processes=4)
    pool.map(f, glob('*.asy'))
    But I like something that can be integrated in my "shell life". Anyone know a solution for my problem?

    http://stackoverflow.com/questions/3816 … ash-script
    http://www.mail-archive.com/bug-bash@gn … 05820.html
    Last edited by karol (2009-11-23 00:30:34)

  • Searching for End of line char in a string...and EOF in string.

    Suppose I open up a file and read it right into a StringBuffer. Once I have that, how can i searching using StringBuffer.indexOf(whathereforEOL) for a end of line, i suspect its perhaps some sort of escape character but I am not sure what it is in java or if java even uses escape characters.
    I really need
    .indexOf(EOL); somehow, and perhaps .indexOf(EOF); //if end of file character is retrieved using a StringBuffer that was completed using a BufferedReader based on a input stream reader.
    Thanks for any info here,
    Shane

    End-of-line is denoted in a platform-specific way.
    Some variations depending on the platform:
    "\r"
    "\n"
    "\r\n"
    A sidenote. I remember some platforms maintaining the notion of "sequential" (and h�las, of "index-sequential") files. Unix and Windows store the files as byte streams without OS-imposed internal structure, that is the point of view of C as well.
    But if you use BufferedReader.readLine() you get the lines one after the other.
    EOF is handled by the OS. You will not read an "EOF" marker.
    -1 rather denotes in the API that end-of-file is reached.
    There is no way to actually read -1 as a byte or a character from a file or other data source.

  • How to search for a new line character in sql

    hi..i am using oracle 10g.
    basically i am looking for usage of columns.I want to see which all columns are used in
    joins.
    this is the quey i have written.
    but
    if there a new line between WHERE ,AND those scenarios are ignored.how to take care of these new line characters?
    SELECT DISTINCT s.TYPE, s.NAME, s.owner, table_name, column_name --,line,text
    FROM all_source s, cols c, all_dependencies d
    WHERE s.NAME = d.NAME
    AND d.referenced_name = c.table_name
    AND c.table_name = 'WSF_EDUCATION_ORGUNIT'
    AND column_name ='ORGUNIT_TYPECODE_OID'
    AND d.TYPE = s.TYPE
    AND d.TYPE <> 'PACKAGE'
    AND d.owner = s.owner ---FOR OVERLOADED OBJECTS
    AND ( (UPPER (text) LIKE
    '%' || 'AND' || '%' || column_name || ' ' || '=%'
    OR (UPPER (text) LIKE
    '%' || 'AND' || '%=' || ' ' || '%' || column_name
    || '%'
    UNION ---if there is where
    SELECT DISTINCT s.TYPE, s.NAME, s.owner, table_name,
    column_name ----,line,text
    FROM all_source s, cols c, all_dependencies d
    WHERE s.NAME = d.NAME
    AND d.referenced_name = c.table_name
    AND c.table_name = 'WSF_EDUCATION_ORGUNIT'
    AND column_name ='ORGUNIT_TYPECODE_OID'
    AND d.TYPE = s.TYPE
    AND d.TYPE <> 'PACKAGE'
    AND d.owner = s.owner ---FOR OVERLOADED OBJECTS
    AND ( (UPPER (text) LIKE
    '%' || 'WHERE' || '%' || column_name || ' ' || '=%'
    OR (UPPER (text) LIKE
    '%' || 'WHERE' || '%=' || ' ' || '%' || column_name
    || '%'
    )

    Hi,
    Not sure if I get it, but you can look for characters using the ascii and chr functions.
    You can change them using replace:
    A new line:
    SQL> select ascii('
      2  ') from dual;
    ASCII('')
            10(Just press enter between the quotes)
    Example how to replace it with a space:
    SQL> with t as ( -- generating test string:
      2  select 'this string has
      3  a new line' str from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select str
      9  ,      replace(str, chr(10), chr(32))
    10  from   t;
    STR                        REPLACE(STR,CHR(10),CHR(32
    this string has            this string has a new line
    a new lineIf that isn't clear of when I'm missing the point then please post some narrowes down examples of what you get now and your desired output. Remember to put the tag around any code example you're posting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • ESS - Bank - Payment method  showing blank line

    Hi All,
    I have two specific problem  for ESS - Bank.
    1. In the ESS - Bank Information, we have a requirement to restrict Payment Method for a specific condition.
       If employee's current Payment method (in IT09-ZLSCH) is 'E' (BAC Transfer), then he can not choose any other Payment method  in the Edit section. In order to accomplish that. we have used Badi HRPAD00INFTYUI and in the method FILL_HELP_VALUE, we have put the code to restrict Payment method to current payment method for above condition.
         Sample Code:
                     READ TABLE help_values INTO help_values_wa   WITH KEY fieldname = 'ZLSCH'.
                     ASSIGN help_values_wa-data->* TO <tabs>.
                    if pa_0009-zlsch = c_pay.
                    Loop at <tabs> ASSIGNING <wa_tab>.
                    assign COMPONENT 1 of structure <wa_tab> to <comp>.
                    if <comp> NE  c_pay.
                   delete <tabs>.
                   endif.
                  endloop.
                  endif.
    As a result, we are getting 2 drop down values. One is Bank Transfer (As desired) and one Blank Line. In debug mode we saw help_values table only contains Bank Transfer. Thus I think this Blnak line is getting added by other SAP code.
    Please help me for this issue and I would like to know how I can get rid of this Blank Line.
    2.  In Bank, We have created two Iviews. one for Edit. and Another for New Bank Account. Both of these hit BAdi HRPAD00INFTYUI in the Back end. For new Bank Account, BAdi implementation should be skipped so that user can have all Payment methods available even if his current Payment Mehtod is Bank Transfer. We have used Decoupled Framework also.
    Please let me know how can I deactivate /filter above  Badi implementation for New Bank Account.

    Guys,
    I feel, there is a SAP bug for the blank line in the web dynpro drop drown. In bank application, payment method will have a blank line entry by default. After doing a system debugging, I am sure that, this is not a back end bug. While system is binding  values  to frond end pick list (Dropdown box) element, it includes a blank line for unknown (to me at least) reason.
    Thus, the only option to get rid of this issue is to make the field mandatory.
    Can anybody reply for my second question that I have posted.
    2. In Bank, We have created two Iviews. one for Edit. and Another for New Bank Account. Both of these hit BAdi HRPAD00INFTYUI in the Back end. For new Bank Account, BAdi implementation should be skipped so that user can have all Payment methods available even if his current Payment Mehtod is Bank Transfer. We have used Decoupled Framework also.
    Please let me know how can I deactivate /filter above Badi implementation for New Bank Account.
    Regards,
    Kalikinkar

  • Blank Line in output file

    Hi,
    I have a requirement for a blank line in between the Static data and dynamic values part as shown below
    Flag='Yes'
    Ready='No'
    Column1     Column2      Column3
    a                 b                 c
    d                 e                  f
    g                 h                  i
    Here after  "Ready='No'" there is a  blank line before the starting of Column1. I want to achieve that through xsd. I have tried with the nillable='true' , its not working.I am using SOA 11.1.1.7.0. Please help.
    Thanks,
    Abhishek

    Hi !
    Why are you using File.endSeparator '0'. ?
    Are you sure your input data doesn't have those 3 blank records in the end? Check the message payload in the sxmb_moni transaction.
    Regards,
    Matias.

  • "clear recent history" is not lit up, can't activate; I have an extra blank line under all these editing icons which I do not want?????Yahoo says it is your issue; also when I copy for instance a screenshot (see below)

    1)trying to clear cache: when I click tools,options, "clear recent history" is not lit, I do not know what else to say. I tried to copy the screenshot sample, but it wouldn't let me.<br />
    2) On a page: the items appear in this order -<br />
    a)Header line:Firefox symbol Ask question or whatever I am seeking<br />
    b)2nd line: the words: File, Edit, View, etc. <br />
    c) 3rd line:arrows then 7 icons for editing which appeared one day, a small window that tells where I am with a star and then a window with
    google's symbol and a small window with a magnifying glass.<br />
    d)4th line: a wide empty line<br />
    e)5th line: a small window telling what I am doing ie Ask a Question etc. then a plus sign in a gray box and then nothing follows. <br />
    Yahoo says that the blank line and the icons are Firefox's issue. <br />
    I never chose to have icons for editing instead of the words. I do not know how they got there. I had some problems for a number of weeks (1/4/11 to 2/5/11 because all of the 2nd line had disappeared and I had no bookmarks. Yahoo was completely ineffective and I got disparate yesterday and started click all over the screen and suddenly the words of that line appeared again as well as all my bookmarks were back.?????odd. So all this maybe related. I just would rather not have that blank line as it lowers my screen.
    3) cont'd: to my desktop I cannot retrieve from my desktop. I click to open it and the page opens, but it keeps opening and opening and on and on and won't stop, so I have to close the tab and sign in again. This has happened about ten times recently. I guess that is it.

    * Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Automatically start Firefox in a private browsing session"
    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • A hyperlink click to a pdf document in a website does not open a pdf document instead presents a blank page "searching for bookmarks"

    a hyperlink click to a pdf document in a website does not open a pdf document instead presents a blank page "searching for bookmarks"

    Check the settings as shown in the [[opening PDF files within Firefox]] article.

  • Help:i need a code for making a new text file then adding 1 blank line

    i have done makng load, edit and save for a command line text editor. now my problem is, i dont know how to make a new blank text file and store it on the current directory. and i need to have that new text have 1 blank line with full of white space. help please.

    PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("NewBlankTextFile.txt")));
    pw.println("                                                                                                                                         ");
    pw.close();

  • More than 1 blank line available for input in IP-Excel based?

    Hello,
    We are converting a large BW-BPS application (> 200 active users) to IP.
    A major requirement is the availability of the "blank screen" in Excel, similar to the BPS standard screen, where users can cut-and-paste multiple lines into it.
    IP - Excel-based appears to give only one blank line available for input at the bottom of the query.  Is there a setting or change available to give 20 blank lines, similar to the UPP_SET_DEFAULT_DUMMIES program for BPS?
    If this is not available it would be a large drawback to converting to IP, as users require pasted-in input from other systems, or "templates" where they change just a few numbers or rows each month, etc.
    Thanks,
    Aaron Benner

    Mayank, thanks for the info.  I knew about the analysis item option in the web, unfortunately I'm only interested in the Excel option.
    Marc, can you shed any light on this subject, as pertains to the Excel-based IP?
    Thanks, Aaron

  • Mountain Lion Mail cannot search for non-alpha characters in Subject Lines

    Under 10.8.3, Mail 6.3 often cannot successfully find messages if the search string contains a non-alpha character.
    I have only tested this searching for Subject lines that are KNOWN to contain non-alpha characters
    Specfic examples:
    Subject starts with "[ABC..."
    Mail cannot find it if you search using "[ABC"
    Mail CAN find it if you search using just "ABC"
    Subject contains the numeral "2"
    Mail cannont find it if you enter "2" as the search string...even if you further constrain the search to "Subject contains: 2"
    Other problem characters I have found:
    The failure when using square bracket is a real pain since a lot of mailing lists are tagged using strings wrapped in square brackets.
    Sometimes it WORKS when I include multiple non-alpha characters in the search string, like "55" or "4/19"
    Anyone else see this?

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Log out and log back in. Launch Mail and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combinationcommand-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • Blank line in address display for country mexico

    Hi All,
    I am using address node to print the addrees using address no in smart forms. It is working fine but when the country is mexico the one blan line is printing after street address. 
    Please let me know how to avoid blank lines.
    Your quick responses are higly appriciated and points will be rewarded as well.

    Hi Venkat,
      Try using ADDRESS-ENDADDRESS for the address text element:
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/80318f454211d189710000e8322d00/frameset.htm
    Regards,
    Ravi

  • Open email, search for text, delete X number of lines and/or paragraphs?

    How would one go about this?
    I have existing code that uses the objActionsMenu.Execute to "resend" the message, essentially creating a new email that I can edit.
    I would like to be able to:
    1) Search for a keyword
    2) Move to the end of the line and/or paragraph
    3) Delete the contents
    The reason is that I often receive important emails with 50+ lines of names and email addresses on the "To:" or "CC:" lines. I want to quickly and easily remove these so I can get to the important part of the email.
    Am I going about it the right way? If so, how would I accomplish this? Thanks.
        

    How would one go about this?
    I have existing code that uses the objActionsMenu.Execute to "resend" the message, essentially creating a new email that I can edit.
    I would like to be able to:
    1) Search for a keyword
    2) Move to the end of the line and/or paragraph
    3) Delete the contents
    The reason is that I often receive important emails with 50+ lines of names and email addresses on the "To:" or "CC:" lines. I want to quickly and easily remove these so I can get to the important part of the email.
    Am I going about it the right way? If so, how would I accomplish this? Thanks.
    I think you maybe in the wrong forums :). This is for Excel and not Outlook. This is a general VBA question though. The easiest way to do this is the following:
    -Assign the content of the email body to a string variable.
    -Use the split function to split at the keyword, and keep the string portion BEFORE the keyword.
    -Assign the split string back to the email body so something like this:
    Public Sub ReplyWithAttachments() ' Ensure reference to Word Object model is set
    Dim rpl As Outlook.MailItem
    Dim itm As Object
    Set itm = GetCurrentItem()
    If Not itm Is Nothing Then
    Set rpl = itm.Reply
    rpl.BodyFormat = olFormatHTML
    rpl.display
    End If
    Dim objDoc As Word.Document
    Set objDoc = rpl.GetInspector.WordEditor
    Dim txt As String
    txt = objDoc.Windows(1).Document.Range.text
    txt = Split(txt, "To")(0) '
    objDoc.Windows(1).Document.Range.text = txt
    End Sub
    Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
    Case "Explorer"
    Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
    Case "Inspector"
    Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
    GetCurrentItem.UnRead = False
    Set objApp = Nothing
    End Function

  • How do I search for lines with a particular pattern and delete them when a match occurs

    How do I search for lines with a particular patter and delete them when a match occurs? For example delete lines containing SUB_NAME = "?" where ? is any string. 

    How do I search for lines with a particular patter and delete them when a match occurs? For example delete lines containing SUB_NAME = "?" where ? is any string. 
    Lines in what? And what language are you using to develop with?
    Are the lines in a text file? A RichTextBox? A TextBox? Some other control? A List(Of String)?
    Is there some expectation by you that by providing what you wrote in your question post that the knowledge in your mind about what you are thinking about will mysteriously emanate to anybody reading your post so all of the sudden your knowledge will
    become their knowledge and they will be able to provide you with an answer as they will suddenly understand what you are trying to do? Because that's probably impossible. Most people try providing enough information in a question so anybody, even stupid people
    like me, can understand what they want. Maybe you should try that. As well as selecting an appropriate forum for your question in the future. Usually a question like this is related to programming in a particular language therefore a language forum may be
    a good choice. Or not.
    La vida loca

Maybe you are looking for

  • HP 3050 how can I print out the printercod​e / e-mailadre​ss of the printer??

    HP 3050 XP/7 For using the ePrintserviceI have to fill in the printercode / e-mailadress of the printer. How can I print out these informations. I already printetd out the Net configuration page (Netzwerkkonfigurationsseite) and the printerstatus (Dr

  • Classes not working

    ok so i have this class i made:      public class George {           public void talk(){      System.out.println("meow"); and then i call it with this:           George Speech = new George;                Speech.talk(); That is done in the trivialapp

  • Using After Effects with Premier Pro CS5

    I'm trying to add some text effects over my video, but I'm really stuck right now getting After Effects and Adobe Premier to work together. From the tutorials I've watched online, I've been trying to create a dynamic link between the two programs so

  • Install/Wizard Failure

    Hi.  I get the same message using the install disk and using the download.  "The wizard was interrupted before BlackBerry Desktop Software could be completely installed.  Your system has not been modified.  To complete installation at another time, p

  • Trouble with DataGrid's last column width

    I have a datagrid with thirty columns. When I use the mouse to drag the window and resize its size,the last column width becomes more and more wide,and the previous column width is squeezed small. If anybody else came accross the same problem,can you