Get the file separator

hi
I have a text file whose content is 1.0 , 1.1
i have to get the separator as ,
Is there any method to get the separator alone

Well the method is still the same my friend...all you havve to do is to change seperator as the input and i feel their is bit of ambiguity i describing your requirement also
Anyways checkout,below example which might be of some help :)
import java.io.File;
import java.util.Scanner;
public class InputFileUtil{
    /**Prints seperated output as per the Input delim/pattern given */
    public void parseFile(String fileName,String inputSeperator){
               Scanner sc = null;
                try{
                     sc = new Scanner(new File(fileName));
                     sc.useDelimiter(inputSeperator);
                     while(sc.hasNext())
                       System.out.println(sc.next());
                }catch(Exception exp){
                       exp.printStackTrace();
                }finally{
                     if(sc != null){
                                 try{
                                     sc.close();
                                     sc = null;
                                  }catch(Exception ep){
                                       ep.printStackTrace();
     public static void main(String s[]){
           Scanner sc = null;
           String patterm = null;
            try{
                System.out.print("Please Enter a delimter Pattern:");
                sc = new Scanner(System.in);
                pattern = sc.next();
                new InputFileUtil().parseFile("fileName",pattern);      
                System.out.println("\nResults....");       
            }catch(Exception ec){
                    ec.printStackTrace();
            } finally{
                if(sc != null){
                      try{
                            sc.close();
                            sc = null;
                      }catch(Exception exp){
                          exp.printStackTrace();
NOTE:* Applied for J2SE 5.0+
and for further reference hope the below might be of some help
http://java.sun.com/developer/JDCTechTips/2004/tt1201.html
REGARDS,
RaHuL

Similar Messages

  • When I try to access iTunes I get 'The file "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes.' But when I try to download iTunes I get error (-42408)...help please.

    When I try to access iTunes I get 'The file "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes. Would you like to download iTunes now?'' But when I try to down load I get "unknown error occurred (-42408)". Don't know what to do next and I can't get into my iTunes library. (I have an iMac, OS10.6.8.)

    Did you uninstall iTunes 11 and replace it with iTunes 10.7? If so, you'll need to go through a few steps to put things right:
    Rename "iTunes Library.itl" to some other name;
    Copy newst ITL file from the "Previous iTunes Libraries" folder into your main iTunes folder and rename it to "iTunes Library.itl";
    Download iTunes 10.7: http://appldnld.apple.com/iTunes10/041-7195.20120912.d3uzQ/iTunes10.7.dmg
    Download/install shareware app called Pacifist;
    Open Pacifist and, separately, mount iTunes DMG file -- drag iTunes PKG file into Pacifist and install iTunes via the Pacifist application -- be sure to answer yes to replacing everything Pacifist asks about;
    Enjoy iTunes 10.7.
    Cheers,
    trane

  • The File class ignores the file.separator system property?

    I am saving the pathname of a file to a String using:
    String pathString = myfile.getAbsolutePath();
    This gives me e.g. "D:\Java\Projects\myfile.txt" on Windows XP
    If I want to save this value to a properties file, then load it in a new invocation of the program, this string will not be recognised as a valid pathname because of the backslashes.
    So I want to use forward slashes as the file separator char.
    I tried:
    System.setProperty("file.separator","/");
    However, this setting seems to be ignored by the File class, as I still get the same string with backslashes from the getAbsolutePath() method.
    Can anyone help please?

    Yeah... I've used that before. Never recalled having problems. I can't, however, recall if there were file paths saved.
    Just tested with this:
    import java.io.*;
    import java.util.*;
    public class Props {
         public static void main(String[] args) {
              try {
                   Properties p1 = new Properties();
                   p1.put("file", new File("C:\\test\\Props.java").getAbsolutePath());
                   FileOutputStream out = new FileOutputStream("Props.properties");
                   p1.store(out, null);
                   out.close();
                   FileInputStream in = new FileInputStream("Props.properties");
                   Properties p2 = new Properties();
                   p2.load(in);
                   System.out.println("p1: " + p1.getProperty("file"));
                   System.out.println("p2: " + p2.getProperty("file"));
              } catch(Exception e) {
                   e.printStackTrace();
    }created this:
    #Tue Jun 21 10:53:38 EDT 2005
    file=C\:\\test\\Props.java

  • File Adapter - how to get the file count from a folder

    Hi All,
    I have a requirement that have to poll a directory when the file count is reached to number N (ex:number of files avilable in folder is 5) otherwise it should wait and not pick any of the files. Is it possible to get the file count from a folder using file adapter ?? otherwise please suggest me an approach to achieve this requirement.
    Thanks,
    JJ

    Hi Sarath,
    Thank you for your reply.
    Go with the list files operation of file adapter it will gives you the number of files in the specified folder as you given. . - this step is already done.
    When the number of files reaches your count startup your webservice that which can polls the files. . . - how can i acheive this?? Have to poll the directory and process the number files - please let me know, what could be added to the webservice which is being invoked after cheking file count from parent process.
    The reason for the above question is - we cannot use ReadFile operation in second webservice because it will be automatically triggered when the file is avilable. Also SyncRead operation supports reading one file in b/w bpel process. Kindly explain me the implementation steps.
    Thanks,
    JJ

  • FM to get the file from application server to presenatation server automati

    Hi!
    In my upload program I am egtting the error log file onmy application server directly. Is there a function module or a way that in my abap code I can mention to bring the file or transfer the file to the presentation server . As my program is been run in the back ground so I cannot directly get the file on the presenattion server, so I need to bring it back on teh presentation server back to see teh eror log.
    I would like my program to do the transfer in background itself so that I can see the error log on a daily basis from my local file .
    Thanks
    when 'X'.                      "X is application server
    *         TRANSLATE p_err USING '\/'." correct slash for unix
          open dataset p_err2 for output in text mode encoding default.
          if sy-subrc = 0.
            loop at t_err into s_nts.
              transfer s_nts to p_err2.
              if sy-subrc ne 0.
                message i010(ad) with p_err2 'Download Failed'.
              endif.
            endloop.
            close dataset p_err2.
          else.
                message i010(ad) with p_err 'dataset could not be found'.
            sy-subrc = -1.             "Maintain error condition
          endif.
    *        endif.
          when ' '.                      "Blank is presenation server
            translate p_err using '/\'."correct slash Dos file
            call function 'DOWNLOAD'
              EXPORTING
                filename = p_err
                filetype = 'ASC'   "FTYPE set to DAT in DATA seg
              TABLES
                data_tab = t_err.
            if sy-subrc ne 0.
              message i010(ad) with 'File ' p_err 'cannot be located.'.
              sy-subrc = -1.             "Maintain error condition
              exit.
            endif.
        endcase.
      ENDIF.
    Thanks

    SO , after reading all , I assume that there is no way in which when I run the background job and get a errro file on application server can be retrievd on my presenattion serevr during the background job run. I was thinking that theer might be a functionn module which will convert the application server file into presenttion server file during the program run in background and store it in the location provided.
    I was trying to use FM  CALL FUNCTION 'C13Z_APPL_TO_FRONT_END' and  CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER' but using teh first one asks for source file and destination file name during teh program run and as it runs in background it cannot be provided again and again and teh second one dosent seem to work.
    Thanks

  • Help ...how to get the file size on a server

    Hi.I use this code to parse a file that is on a server.
    The question is: how can i get the file size (bytes size)?
    Thanks.
    //Open the file for reading:
    URL u = new URL(entry);
    InputStream inputXML = u.openStream();
    //Build document:
    DocumentBuilder builder = factory.newDocumentBuilder();
    doc = builder.parse(inputXML);

    Try this instead:
    URL u = new URL(entry);
    URLConnection conn = u.openConnection();
    // get the file size
    int size = conn.getContentLength();
    // open the input stream from the URLConnection (which is functionally the same as opening it directly from the URL)
    InputStream inputXML = conn.getInputStream();
    Shaun

  • How do I get the file names on a customized proof sheet?

    How do I get the file names on a customized proof sheet?

    Actually, I really don't know what you say.
    But when you see the properties of a file in Windows, you can see there are two file size. One is called "SIze" and the other one is called "Size on disk".
    Therefore, I would like to know the size on disk but not just the size.

  • How to get the files in presentation server while uploading?

    how to get the files in presentation server while uploading?
    give me the function module name

    Hi,
    PARAMETERS:  P_FILE LIKE RLGRAP-FILENAME DEFAULT C_PRES.  "Prsnt Srvr
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          DEF_PATH         = P_FILE
          MASK             = ',..'
          MODE             = '0 '
          TITLE            = 'Choose File'
        IMPORTING
          FILENAME         = P_FILE
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.

  • Exit CL_GUI_FRONTEND_SERVICES= FILE_OPEN_DIALOG once I get the file name

    Hi
    I have where I have a selection screen that finds the file, you can say where to get the file. After that I need to close that window. How do I close it???
    Below is an example of my program. After I choose the file and execute the program, I have a <b>write</b> statement. I don't see that statement on the screen. How do i terminate the input screen and display text.
    Parameters :  AUSZFILE      LIKE RFPDO1-FEBUMSF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR AUSZFILE.          "mo271101
      DATA: L_FILES TYPE FILETABLE,                            
            H_FILES TYPE FILE_TABLE,                           
            L_RC LIKE SY-SUBRC.                                
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG        CHANGING                                               
          FILE_TABLE              = L_FILES                    
          RC                      = L_RC                       
        EXCEPTIONS                                             
          FILE_OPEN_DIALOG_FAILED = 1                          
          CNTL_ERROR              = 2                          
          ERROR_NO_GUI            = 3                          
          NOT_SUPPORTED_BY_GUI    = 4                          
          OTHERS                  = 5.                         
      IF SY-SUBRC <> 0 OR L_RC < 0.                            
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO       "mo271101
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   
      ELSE.                                                     "mo271101
        READ TABLE L_FILES INDEX 1 INTO H_FILES.              
        AUSZFILE = H_FILES-FILENAME.                           
      ENDIF.
    Write AUSZFILE.
    Thanks in advance

    You must remember the START-OF-SELECTION event here,  after you select the file name and click F8, the START-OF-SELECTION event is triggered, but if it is not there, nothing will happen.
      if sy-subrc <> 0 or l_rc < 0.
        message id sy-msgid type sy-msgty number sy-msgno       "mo271101
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.                                                     "mo271101
        read table l_files index 1 into h_files.
        auszfile = h_files-filename.
      endif.
    start-of-selection.            "<--  Add this
      write:/ auszfile.
    Regards,
    RIch Heilman

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • How is it posible to get the File name, size and type from a File out the H

    How is it posible to get the File name, size and type from a File out the HttpServletRequest. I want to upload a File from a client and save it on a server with the client name. I want to conrole before saving the name, type and size of the file.How is it posible to get the File name, size and type from a File out the HttpServletRequest.
    form JSP
    <form name="form" method="post" action="procesuploading.jsp" ENCTYPE="multipart/form-data">
    File: <input type="file" name="filename"/
    Path: <input type="text" readonly="" name="path" value="c:"/
    Saveas: <input type="text" name="saveas"/>
    <input name="submit" type="submit" value="Upload" />
    </form>
    proces JSP
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="FileUploadBean" %>
    <jsp:useBean id="TheBean" scope="page" class="FileUploadBean" />
    <%
    TheBean.doUpload(request);
    %>
    BEAN
    import java.io.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletInputStream;
    public class FileUploadBean {
    public void doUpload(HttpServletRequest request) throws IOException
              String melding = "";
              String filename = request.getParameter("saveas");
              String path = request.getParameter("path");
              PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.java")));
              ServletInputStream in = request.getInputStream();
              int i = in.read();
              System.out.println("filename:"+filename);
              System.out.println("path:"+path);
              while (i != -1)
                   pw.print((char) i);
                   i = in.read();
              pw.close();
    }

    Thanks it works great.
    Here an excample from my code
    import org.apache.commons.fileupload.*;
    public class FileUploadBean extends Object implements java.io.Serializable{
    String foutmelding = "geen";
    String path;
    String filename;
    public boolean doUpload(HttpServletRequest request) throws IOException
         try
         // Create a new file upload handler
         FileUpload upload = new FileUpload();
         // Set upload parameters
         upload.setSizeMax(100000);
         upload.setSizeThreshold(100000000);
         upload.setRepositoryPath("/");
         // Parse the request
         List items = upload.parseRequest(request);
         // Process the uploaded fields
         Iterator iter = items.iterator();
         while (iter.hasNext())
         FileItem item = (FileItem) iter.next();
              if (item.isFormField())
                   String stringitem = item.getString();
         else
              String filename = "";
                   int temp = item.getName().lastIndexOf("\\");
                   filename = item.getName().substring(temp,item.getName().length());
                   File bestand = new File(path+filename);
                   if(item.getSize() > SizeMax && SizeMax != -1){foutmelding = "bestand is te groot.";return false;}
                   if(bestand.exists()){foutmelding ="bestand bestaat al";return false;}
                   FileOutputStream fOut = new FileOutputStream(bestand);     
                   BufferedOutputStream bOut = new BufferedOutputStream(fOut);
                   int bytesRead =0;
                   byte[] data = item.get();
                   bOut.write(data, 0 , data.length);     
                   bOut.close();
         catch(Exception e)
              System.out.println("er is een foutontstaan bij het opslaan de een bestand "+e);
              foutmelding = "Bestand opsturen is fout gegaan";
         return true;
         }

  • Unable to get the file system information for: \\****servername\E$\; error = 64 Unable to distribute content to DP

    One of our DPs has stopped loading content. 
    I've research for quite a bit and cannot find a clear cut reason to this.  This server only has a DP role, I verified sharing permissions, all looked good. This DP has been running just fine for the last year or so and all sudden it will no longer load
    packages.  The disk drive is still present I can still reach the hidden share \\servername.com\E$
    Verified that the SMSSIG$ folder is there and the last entry is from 4/23/2015 
    SCCM 2012 R2 
    OS 2008 R2 Standard
    Any help is greatly appreciated!
    Here's a snipit from the distmgr.log
    Start updating the package on server ["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\...
    Attempting to add or update a package on a distribution point.
    Will wait for 1 threads to end.
    Thread Handle = 0000000000001E48
    STATMSG: ID=2342 SEV=I LEV=M SOURCE="SMS Server" COMP="SMS_DISTRIBUTION_MANAGER" SYS=***.com SITE=1AB PID=2472 TID=8252 GMTDATE=Thu Apr 30 19:12:01.972 2015 ISTR0="SYSMGMT Source" ISTR1="["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\"
    ISTR2="" ISTR3="" ISTR4="" ISTR5="" ISTR6="" ISTR7="" ISTR8="" ISTR9="" NUMATTRS=2 AID0=400 AVAL0="CAS00087" AID1=404 AVAL1="["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\"
    SMS_DISTRIBUTION_MANAGER 4/30/2015 2:12:01 PM
    8252 (0x203C)
    The current user context will be used for connecting to ["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\.
    Successfully made a network connection to \\*****.com\ADMIN$.
    Ignoring drive \\*****.com\C$\.  File \\*****.com\C$\NO_SMS_ON_DRIVE.SMS exists.
    Unable to get the file system information for: \\*****.com\E$\; error = 64.
    Failed to find a valid drive on the distribution point ["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\
    Cannot find or create the signature share.
    STATMSG: ID=2324 SEV=E LEV=M SOURCE="SMS Server" COMP="SMS_DISTRIBUTION_MANAGER" SYS=sccmprdpr1sec2.mmm.com SITE=1AB PID=2472 TID=8252 GMTDATE=Thu Apr 30 19:12:55.206 2015 ISTR0="["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\"
    ISTR1="CAS00087" ISTR2="" ISTR3="30" ISTR4="94" ISTR5="" ISTR6="" ISTR7="" ISTR8="" ISTR9="" NUMATTRS=2 AID0=400 AVAL0="CAS00087" AID1=404 AVAL1="["Display=\\*****.com\"]MSWNET:["SMS_SITE=1AB"]\\*****.com\"
    Error occurred. Performing error cleanup prior to returning.
    Cancelling network connection to \\*****.com\ADMIN$.

    Error 64 is being returned which is simply "the network name is no longer available".
    There can be a number of reasons for this from SMB compatibility issues (2003 servers wont support SMB2), to the expected and actual computer name of the boxes don't match (tries to authenticate with server.tld.com when the actual name is srv-01.tld.com and
    you just put a C-name in). I'd start from the top:  Try opening said share from the Primary Site server as that's the box doing the work.  Verify the IP and computer name is legit and that no one has played ACL games between the two systems (remember
    RPC only initiates/listens on port 135 but established connections are up in the dynamic port range).
    At the end of the day it's an issues "underneath" SCCM, and not an SCCM problem specifically. 

  • Is there any way to get the files from other computer ?

    Hai all,
    I have 2 computers connected. I know the IP address of other computer. Is there any way to get the files from other computer. (for e.g. I want to get the files from specific folder. In Java netwroking is it possible? (Any programs)
    regards,
    Namanc

    Bro Take it easy.
    Think you need to send a Image file named ("abc.gif")
    now develop a server using ServerSocket and connect it in local IP and any PORT
    For example i think ur server is connected in "localhost" and 9000 port.
    Now make ur server educated using some commands.
    For example:
    FileName: <File Name String>
    [Means new file is sending by connected client]
    FileSize: <File size long or int value>
    [ So that ur server can determind about the total length of sender file]
    DataModeOpen
    [Now your client will send its image data, this command means your client software is sending data]
    fjadlkfjaofaijojfwoeiurfodkjflsajlfksa
    l23j4lj23lkjlasjfoq23j4rokjelfkjasldkf
    2o3j4lk2j3ljslakdjf2l3j4 l23kjlk23k4j
    DataModeClose
    [Means file sending finished]
    Close
    [Means your client connection is closed]
    Now develop a client supporting this command.
    For example(Server):
    String getFileName=null;
    long getFileSize=0;
    public handleCommand(String getCmd) {
        if(getCmd.startsWith("FileName")) {
                String[] splitData=getCmd.split(":");
                this.getFileName=   splitData[1];
                outPutStream.writeBytes("+OK");
        } else if(getCmd.startsWith("FileSize")) {
                String[] splitData=getCmd.split(":");
                this.getFileSize=Long.parseLong(splitData[1]);
                outPutStream.writeBytes("+OK");
        } else if(getCmd.startsWith("DataModeOpen")) {
               //data mode open so receive data
              receiveData();
              outPutStream.writeBytes("+OK");
        } else if(getCmd.startsWith("DataModeClose")) {
              //close client socket
             getClientSocket.close();
    }For client:
    DataInputStream dataIn=null;
    BufferedOutputStream bout=null;
    public sendFile(bytes[] getBytes) {
            //if ok found then do other or show error message
        if(sendCmd("FileName:"+getFileName)) {
            if(sendCmd("FileSize:"+getFileSize)) {
                if(sendCmd("DataModeOpen")) {
                   bout.write(getBytes);
                } else {
                   showError(3);
            } else {
                   showError(2);
       } else {
            showError(1);
    }i think it will help u

  • [CS3][JS] How to get the file type of current document

    Hi,
    How to get the file type of current opening document (e.g., tif, jpeg, png) using JavaScript with Photoshop CS3.
    I am using file object the open the files one by one in the folder (the files sometimes don't have the extensions).
    If the current document is in tiff format then I need to convert to 8-bit, if its an Jpg image then needs to ignore the file.
    Regards,
    Karthik

    Do you really need to know the file type? What about just checking the bit depth?
    var doc = activeDocument;
    if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) {//Not 8 bit
    doc.bitsPerChannel = BitsPerChannelType.EIGHT;
    //do your save etc
    }else{
        //Ignore

  • TS1627 I cannot open iTunes. This is the message I get:  "The file iTunes library .itl cannot be read because it was created by a newer version of iTunes. Would you like to download iTunes now?"  I did a download and it is up to date, but still won't open

    I cannot open iTunes. This is the message I get:  "The file iTunes library .itl cannot be read because it was created by a newer version of iTunes. Would you like to download iTunes now?"  I did a download and it is up to date, but still won't open.  HELP

    See Empty/corrupt iTunes library after upgrade/crash.
    tt2

Maybe you are looking for