How to create a method for reading a file

i tried to make it as static method for reading a file and
then to return string
is this code correct?
          public static String fileMaterial(String fileName)
               fileReader = new BufferedReader(new FileReader(fileName));
               info = fileReader.readLine();
               while(school != null)     {                    
                    return info;
                    info = fileReader.readLine();

I created a class you might want to look at. I come from a world of C and love fgets() and other FILE stream functions. I created a class that uses the Java I/O buts to the calling application behaves like fgets and such. The block of code where I do the calling in the calling program even looks like C. In my class I capture almost all errors and set error buffers to the errors. The calling program looks at the return to see if it succedded or errored.
BuffIO new = BuffIO.fopen("fiilename", "r");
String s;
if((s = new.fgets()) == null)
System.err.println("error reading file: " + new.ferror());
That would be waht the calling program does

Similar Messages

  • How to create a password for the pdf file

    In Adore Acrobat XI, how to create a password for the file? The help states going to Tools Menu and clicking on Protection tab - but there is no such option. In the file - properties - security screen, it shows the security details but does not allow to edit it.

    I think you may be mixing up two different products: Adobe Reader (free), and Acrobat ($$).

  • Why no simple method for reading text files

    I'd like to know, after all this time why there is no simple method of reading ext files into a string.
    Yes, yes, I know all about buffered readers, (it took me long enough to figure them out) but they are cumbersome and seem to change every release (how many file methods have been deprecated...)
    Here's what I'm looking for:
    file.open();
    file.read(String);
    file.close();
    No single character at a time, no loop - the whole file into a single string in one shot. If buffers are used, i want it hidden.
    Perl, PHP, VB, C# all have this. Even Java has it when you write to a file.
    So why not on read?
    Yes, buffered streams are very elegant, but for what most programmers want to do, they are overkill and annoying.

    Just Dennis Ritchie's little joke.
    Do you have a better reason for wanting the feature
    other than that some other languages have it?Yes. It would save me time and help dozens of new programmers who continually ask this question in this and other forums. It is in other languages because people use it and want it - clearly Jarkata saw the need. If you don't like the idea, then I won't argue the point. We agree to disagree.
    Also did you have an answer for my question?in java.io.file you can do the following: (i've used it, it works) Granted, you still have to use the buffered output streams, which in my opinion should be abstracted for a simple text read and write.
    BufferedWriter outputStream = new BufferedWriter(new FileWriter(fileNewPath));
    outputStream.write(fileContent);
    outputStream.close();

  • How to Create A Method that reads out JAVADOC form JAVASRC

    Hey everyone!
    I need to develop a Method that reads out the JavaDoc from A certain Javasrc-File.
    That method should look like this :
    String readJavaDoc(String MethodName, String src)
    So the first Parameter is the Name of the Method to witch the JavaDoc should be retrived.
    E.g. :
    String s = test.readJavaDoc("getName", "Foo.java");
    -> read out JavaDoc from Foo.java and retrive only Documentation to the Mehtod "getName()".
    Is this possible or somithing like this??
    Thanks for any help!
    P.S. Sorry for my bad english.

    I have a feeling that you didn't fully think this through. What do you do in case of overloaded methods? Which Javadoc do you return?
    Apart from that, it'd require either some text parsing, or you could try to find a library that can deal with Javadocs. I'm sure some like those exist. Google a little. You'll find stuff like this:
    http://java.sun.com/j2se/javadoc/faq/index.html

  • Index - How to create an index for multiple InDesign files?

    Hi everyone,
    I'm using InDesign CS2 to create a 250 page catalogue. Most of it is finished now, and I've come to creating the index.
    The catalogue is spread over about 10 InDesign files. How do I create an index for this? No paragraph styles were set up when it was started, but there are character styles.
    I've done some searching - does it need to be booked so I Can index? And can I book it without paragraph styles?
    (I've only been using InDesign for about a year, mostly self taught.)
    Thanks in advance :)
    Naomi

    Creating a book from your files should be no problem at all. ID does
    i not
    synchronize styles across documents -- unless you order it to! (That's what the checkboxes at the left of the book documents are for. Do Not Use, in your case.)
    The Index function itself is book-savvy, but you might want to search this forum for a few recurring problems.

  • How to Create a Button for Reader Users to Save XML Data File?

    The "Submit via Email" tries to launching the local email software, like outlook express. But public computer tends to use internet emails.
    I am thinking of creating a button, allowing the reader users to save xml data filled in the form (same as the "submit via email" produces) somewhere.
    anyone has a clue?
    Thanks a lot!

    You could create the shortcut at one machine, then copy it to the target as part of the logon script. Note also that this line contains an error:
    "C:\Users\%userprofile%\Desktop\Org_chart_test.lnk"
    It should read:
    "%userprofile%\Desktop\Org_chart_test.lnk"

  • How to create a link for download a file in text format

    Hi expect,
    I want to create a link when I link that link a text file should get download which i'm specified in jsp page. I tried by using hyper link it didn't get downloaded just it opened as it is. How can I resolve the problem.

    Swati.S wrote:
    in href provide another jsp name or servlet and pass filename as request parameter to this jsp or servlet. In called jsp or servlet set content type to application/forcedownload.Yes, that works (usually), but, IMHO, is nothing but a hack that you shouldn't use (and I could care less how often it is currently used in varying hacked scripts, such as this bogus force-download PHP script I've seen). That is an invalid MIME type (or at least unofficial/non-standard mime tye that most browsers will have no association for), so, since the browser doesn't know what to do with it, it'll ask the user what to do. And even that is not 100% certain. All I need do is create a mime-type to application association for that MIME type and, guess what, it doesn't work again (at least not the way you intended).
    The server should not be concerned with what the client does with the file linked to.

  • How can create color table for "write bmp file.vi"?

    i want to create a color table for a 8 bit bitmap.The color table is the input of "write bmp file.vi". how can i make it?
    thanks!

    > i want to create a color table for a 8 bit bitmap.The color table is
    > the input of "write bmp file.vi". how can i make it?
    > thanks!
    >
    There is a color control on the front panel numerics palette. A color
    in LV is a four byte xRGB formatted number. So you can make an array of
    the color numerics and set them by hand or format the numbers however
    you like. If unwired it will use the LV color palette which is pretty
    much the HTML palette.
    Greg McKaskle

  • How to creating a default for batch naming files?

    I am currently going through a whole bunch of projects and am trying to batch rename the images. Each time, I have to make the changes I want in the batch rename box. Is there a way of creating a custom default (e.g. year, name, number) so that I don't have to start all over again each time i call up the batch naming box?

    in the Version Name Format drop down click edit ...
    from there click the + on the left side ... a new one will appear ... called untitled ... rename it and on the right drag items from the include section to the format section up above it ...

  • How to create an instance for RemoteSession without using create() method

    How to create an instance for RemoteSession without using create() method?

    What's RemoteSession? Not in the JDK. And does the question have anything to do with concurrency?

  • HOW TO CREATE SEVERAL folder for the generation and READING FILE

    HOW TO CREATE SEVERAL folder for the generation and READING FILE WITH THE COMMAND utl_File.
    please give an example to create 3 folders or directories ...
    I appreciate your attention ...
    Reynel Martinez Salazar

    I hope this link help you.
    [http://www.adp-gmbh.ch/ora/sql/create_directory.html]
    create or replace directory exp_dir as '/tmp';
    grant read, write on directory exp_dir to eygle;
    SQL> create or replace directory UTL_FILE_DIR as '/opt/oracle/utl_file';
    Directory created.
    SQL> declare
      2    fhandle utl_file.file_type;
      3  begin
      4    fhandle := utl_file.fopen('UTL_FILE_DIR', 'example.txt', 'w');
      5    utl_file.put_line(fhandle , 'eygle test write one');
      6    utl_file.put_line(fhandle , 'eygle test write two');
      7    utl_file.fclose(fhandle);
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> !
    [oracle@jumper 9.2.0]$ more /opt/oracle/utl_file/example.txt
    eygle test write one
    eygle test write two
    [oracle@jumper 9.2.0]$
    SQL> declare
      2    fhandle   utl_file.file_type;
      3    fp_buffer varchar2(4000);
      4  begin
      5    fhandle := utl_file.fopen ('UTL_FILE_DIR','example.txt', 'R');
      6 
      7    utl_file.get_line (fhandle , fp_buffer );
      8    dbms_output.put_line(fp_buffer );
      9    utl_file.get_line (fhandle , fp_buffer );
    10    dbms_output.put_line(fp_buffer );
    11    utl_file.fclose(fhandle);
    12  end;
    13  /
    eygle test write one
    eygle test write two
    PL/SQL procedure successfully completed.
    SQL> select * from dba_directories;
    OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH
    SYS                            UTL_FILE_DIR                   /opt/oracle/utl_file
    SYS                            BDUMP_DIR                      /opt/oracle/admin/conner/bdump
    SYS                            EXP_DIR                        /opt/oracle/utl_file
    SQL> drop directory exp_dir;
    Directory dropped
    SQL> select * from dba_directories;
    OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH
    SYS                            UTL_FILE_DIR                   /opt/oracle/utl_file
    SYS                            BDUMP_DIR                      /opt/oracle/admin/conner/bdumpRegards salim.
    Edited by: Salim Chelabi on Apr 4, 2009 4:33 PM

  • How to create sharepoint Group with read only permissions using powershell for entire site ?

    How to create sharepoint Group with read only permissions using powershell for entire site (including subsites and top level site)

    Hi
    using (SPSite site = new SPSite(url))
    using (SPWeb web = site.OpenWeb())
    SPUserCollection users = Web.AllUsers;
    SPUser owner = users[string.Format("{0}{1}", "Domain", "Owner Username")];
    SPMember member = users[string.Format("{0}{1}", "Domain", "Default Member Username")];
    SPGroupCollection groups = Web.SiteGroups;
    string GroupName = “Super Exclusive”;//your group name
    string GroupDescription = “Super exclusive group description.”;
    groups.Add(GroupName, owner, member, GroupDescription);
    SPGroup NewSPGroup = groups[GroupName];
    SPRoleDefinition role = Web.RoleDefinitions["Read"];
    SPRoleAssignment roleAssignment = new SPRoleAssignment(NewSPGroup);
    roleAssignment.RoleDefinitionBindings.Add(role);
    Web.RoleAssignments.Add(roleAssignment);
    Web.Update();
    Please 'propose
    as answer' if it helped you, also 'vote
    helpful' if you like this reply.

  • How to create business operation for starting workflows

    How to create business operation for starting workflows from worklist?
    When I call methods that implements business operation from java class everything
    works fine(wlpi-ejb.jar is required), but when I call business operation from
    Studio I can't use classes from wlpi-ejb.jar.

    Business operation is called by WLIS. So, I include wlpi-ejb.jar into WLIS classpath.
    Studio uses deployed EJB from wlpi-*.jar, I don't know why Studio doesn't see
    methods from deployed EJBs when WLIS classpath contains wlpi-ejb.jar.
    "Andrew Pitonyak" <[email protected]> wrote:
    >
    When studio starts, what is your classpath? If you use the included batch
    file to start it, then your class path may not include this :-)
    Andrew
    "Raul" <[email protected]> wrote in message
    news:[email protected]..
    How to create business operation for starting workflows from worklist?
    When I call methods that implements business operation from java classeverything
    works fine(wlpi-ejb.jar is required), but when I call business operationfrom
    Studio I can't use classes from wlpi-ejb.jar.

  • Salmple at How to Create Dynamical Object for RTTC

    Hi all, I need a sample at How to Create Dynamical Object for RTTC.
      you can help me?.

    Hello Martinez,
    I have attached a sample for structure types. With the Where-Used-List on the Create() Method of the various RTTC classes one may find more samples. If you meant with object on OO Type then it is to mention that this is not possible yet.
    Regards
      Klaus
    PROGRAM sample.
    DATA: sdescr1 TYPE REF TO cl_abap_structdescr,
          sdescr2 TYPE REF TO cl_abap_structdescr,
          tdescr1 TYPE REF TO cl_abap_tabledescr,
          tdescr2 TYPE REF TO cl_abap_tabledescr,
          tref1   TYPE REF TO data,
          tref2   TYPE REF TO data,
          comp    TYPE abap_component_tab,
          wa      TYPE t100,
          xbuf    TYPE xstring.
    FIELD-SYMBOLS: <tab1> TYPE table,
                   <tab2> TYPE table.
    sdescr1 ?= cl_abap_typedescr=>describe_by_name( 'T100' ).
    comp     = sdescr1->get_components( ).
    sdescr2  = cl_abap_structdescr=>create( comp ).
    tdescr1  = cl_abap_tabledescr=>create( sdescr2 ).
    tdescr2  = cl_abap_tabledescr=>create( sdescr2 ).
    CREATE DATA: tref1 TYPE HANDLE tdescr1,
                 tref2 TYPE HANDLE tdescr2.
    ASSIGN: tref1->* TO <tab1>,
            tref2->* TO <tab2>.
    wa-sprsl = 'E'. wa-arbgb = 'SY'. wa-msgnr = '123'. wa-text = 'first text'.   INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'SY'. wa-msgnr = '456'. wa-text = 'second text'.  INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'XY'. wa-msgnr = '001'. wa-text = 'third text'.   INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'ZZ'. wa-msgnr = '123'. wa-text = 'fourth text'.  INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'E'. wa-arbgb = 'SY'. wa-msgnr = '123'. wa-text = 'ABAP is a miracle'. INSERT wa INTO TABLE <tab1>.
    EXPORT tab = <tab1> TO DATA BUFFER xbuf.
    IMPORT tab = <tab2> FROM DATA BUFFER xbuf.
    LOOP AT <tab2> INTO wa.
      WRITE: / wa-sprsl, wa-arbgb, wa-msgnr, wa-text.
    ENDLOOP.

  • How to create apple id for mac app store without using credit card and there is no any option for payment none. please tell how to download free apps from mac app store

    how to create apple id for mac app store without using credit card and there is no any option for payment none. please tell how to download free apps from mac app store

    my problem solve by me
    first create apple id
    fill credit card details
    and complete your account creating  process.
    than go to app store or itune store
    login your acount
    click right side  - account button
    than again login for account setting
    next go to payment information and click edit button
    when u enter payment infomation
    click none button in payment method and click done button.
    than ur credit card has been removed.
    but rs. 60 will deducted in your account when u doing this process.

Maybe you are looking for