Wildcard on File.ReceivedFileName property

Hi All,
I am just working with Message Only Scherio . I have a File Receive Location which is taking .txt files(approx 9 types ).
Depending upon file Name I need to route the .txt's file to appropriate folder location through file send port.
For this I have promoted the file Name through custom Pipeline the execute method is like
 IBaseMessageContext messageContext = inmsg.Context;
 string srcFileName = messageContext.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();
string ReceivedFileName = srcFileName.Substring(srcFileName.LastIndexOf("\\") + 1);
 messageContext.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", ReceivedFileName);
            return inmsg;
On message Context property I can see File Name being Populated but when I try to put a filter condition such as file.ReveiveFile =ABC.txt  ,message is not been subscribed.
Is there any thing I am missing here.
Thanks in advance
Abhishek 

Hi Abhishek,
Instead of 
messageContext.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties",
ReceivedFileName); 
Use
messageContext.Promote("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", ReceivedFileName);
Maheshkumar S Tiwari|User Page|Blog|BizTalk
Server : How Map Works on Port Level

Similar Messages

  • The File name property is not valid. The file name is a device or contains invalid characters

    I have an SSIS task that has run successfully for years. They just moved the dtsx to a new server and now it is failing. 
    Issue:
    The task has a data flow that writes a raw file destination. It then has a subsequent data flow that reads the raw file destination. 
    The path and name of the raw file is passed to each of the data flows via the same variable. 
    The raw file resides in a folder on the server in the same path that the dtsx resides in. 
    The task fails with the "The File name property is not valid. The file name is a device or contains invalid characters" error when trying to access the raw file.
    What we have done to troubleshoot:
    1. I ran the task successfully on my local machine so it is definitely a server issue.
    2. The first thing we were seeing was that it failed trying to write to the raw file. The task is set to "Create Always". 
    3. We saw that the dba's copied over the entire directory structure from the old server which included a previously created raw file, so we deleted the raw file.
    4. We reran the task and it successfully wrote a new raw file but then failed on reading the raw file with the same error as above.
    5. We reran the task AGAIN and this time it failed trying to write the raw file throwing the same error as above.
    6. The dba looked at the directory and the account that performs the task has full control.
    7. The dba looked at the raw file that was created and verified that the account that performs the task has full control of the file and that it is the owner of the file.
    Summary:
    The task fails when trying to access the file EXCEPT when the file does not exist. In that situation it can write the file but subsequently fails in accessing it again.

    Hi Whalensdad,
    Based on my research, the issue can be caused by the following reasons:
    There are some invalid characters in the File name at package runtime. In this scenario, just as Russ said, could you please post the value that is in the File name variable? Also use a Script Task with Messagebox.show to show the variable values at runtime.
    May be it changes to others at run time.
    The account runs the package not having access to all the folders in the path. Since you are moving the dtsx file from one server to the current server, do you also move the raw file to the same folder in the current server? Does the user runs the package
    have access to all the folders in the path? To solve this, please ensure that the user has access to all folders and the raw file in the path on the current server.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support
    Please see the response above. I can't use a message box on a server so I logged the values to the database. The resource account has full control to the folder. I haven't been able to get the DBA to check the SQL Agents permissions, but I was always under
    the impression that if you use "Run As" on the task, it will not use the SQL Agent but the account you identify it to "Run As". The "Run As" account has full control on the folder and file.

  • File Upload UI "file Name property"

    Hello Experts,
    I am facing one problem while using this file Upload UI element in Webdynpro ABAP.
    When I am showing the error or information message I want to show the file name also at end of the message.
    But the FILE NAME property reads the whole path of the file like " C:\Documents and Settings\Administrator\Desktop\test.pdf "
    But I want only the file name " test.pdf " .
    How I can achieve this please suggest.
    Thanks
    Pradeep

    Hi,
    Refer the code in above mentioned class to get filename :
    DATA:  wa_dummy TYPE str,
             lt_dummy TYPE STANDARD TABLE OF str.
      DATA:  lv_path TYPE string,
                  lv_cnt type I,
    ev_filename type string.
    ***** iv_path has the path *********
    * Change \ with /
      lv_path = iv_path.
      TRANSLATE lv_path USING '\/'.
    * Split the whole path at /
      SPLIT lv_path AT '/' INTO TABLE lt_dummy.
    * get the filename from the last line of table
      DESCRIBE TABLE lt_dummy LINES lv_cnt.
      READ TABLE lt_dummy INDEX lv_cnt INTO wa_dummy.
      ev_filename = wa_dummy.
    Finally ev_filename will have the name of File.

  • Qn: Getting Around Windows File Lockup Property -- use FileHandling in Java

    I am encountering a problem in developing a software for my business. The task I am trying to achieve is that, I need to update a file (.txt) while that file is being constantly accessed by another program.
    The ultimate setting is this: I will have a software running, constantly reading the content of a feed file (call it info.txt). I have another script running, constantly updating the feed file (info.txt).
    I realized the serious conflict in using the file after I implemented the above setting. With the software (call it AAA) running, I can't make an edit to info.txt even manually. I open up info.txt, make a change, and click save, windows return an error message: "The process cannot access the file because it is being used by another process." If I try to delete info.txt, the error message is "the action can't be completed because the file is open in AAA.exe".
    When I run my (java) script that constantly updates info.txt, the file IO exception is:
    java.io.FileNotFoundException: info.txt (The process cannot access the file because it is being used by another process)
    The software AAA is not that well developped. (It's a foreign software to my enterpise so I can't modify its behavior/source code.) The way it is accessing files locks up the file completely. I thought of temperarily pointing away the reference to info.txt in the software's profile files to allow a temparory edit, but this approach would fail because with AAA running (and I need it to), I can't make any change to any file it's using.
    I consulted one of the main developer of software AAA. He acknowledges this is a problem right now, he would improve it in next release. But meanwhile I would like the set up to work. He told me he programs with .NET, and he provided a line that could help me to get around my problem:
    FileStream fs = new FileStream(@"info.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
    Supposedly, by supplying these arguments, this filestream are allowed to be shared on both writes and reads.
    I am a java programmer, and I've had no experience with .NET. However I did some research and learning, I realized his code is the syntex of C#, which runs in the CLR of .NET framework. I set up C# on my computer and studied some C# beginer tutorial, and comes up with the following script, hoping to solve my problem.
    If it's really true that C# allows to change the access property of a file at a fundamental level, I would open up the filestream of info.txt, allowing it to be shared with both read and write. Once I do that, I can run my script of updating info.txt, and then run the software AAA that keeps refreshing info.txt.
    Trying to achieve the above implementation, I come up with a C# script:
    ================================================
    using System;
    using System.IO;
    class CopyFeed
    static void Main()
    string fileName1 = "info.txt";
    string fileName2 = "info2.txt";
    FileStream fs = new FileStream(@fileName1, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
    StreamWriter sw = null;
    // attempting to unlock part of the file, didn't work
    string contents = File.ReadAllText(@fileName2);
    fs.Unlock(0, contents.Length * 2);
    while (true)
    Console.WriteLine("Copying Feed...");
    string contents = File.ReadAllText(@fileName2);
    try
    sw = new StreamWriter(fs);
    sw.Write(contents);
    catch (Exception e)
    Console.WriteLine("CopyFeed :: " + e.Message);
    finally
    if (sw != null)
    sw.Flush();
    //sw.Close();
    Console.WriteLine("Pausing For 2 sec...");
    System.Threading.Thread.Sleep(2000);
    ================================================
    Supposedly, I will have my java script constantly updating info2.txt . Then I will have this C# script constantly copying the entire content of info2.txt into info.txt.
    (The above script is still buggy, because all it does is keep appending to the file info.txt. I need to find a way that I can clear the content of file at the start of every iteration and just copy over the content of file2. Right now if I execute the script, it will create a infinitely large file as time goes.)
    I wish to seek help with this post:
    Based on the description above, could I find a solution using Java? does Java have file handling capability that interacts with Windows system in a more fundamental level and unlocks the file? Or does any 1 have any better suggestions?
    I've been working on this problem for the past few days and am really stuck. I would sincerely thank any one who offers any insight!

    Good news for you--people have spent billions of dollars on research, in part, to solve those problems!
    The solution is: use a database.

  • Where is the standby file method/property in SMO.Database

    Hello,
    I'm trying to locate the method / property in SMO.Database for StandByFile (undo backup file). I'm able to set it during a restore using SMO.Restore.StandByFile, but I'm currently building a empty DB from the properties of an exisitng DB and this is a property
    I need to at least read from if not modify directly.
    Hoping for some help.
    EDIT: Adding small part of script for context
    # Restore the database
    function Restore-Database ($srv, $dname, $src, $dst, $stby){
    try {
    $SMORestore = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Restore
    if ($stby) {
    Write-Host 'Restoring' ([System.IO.Path]::GetFileName($src)) 'to' $dname 'with standby...'
    $SMORestore.StandbyFile = $tmpdir + $tmpdbname + '_standby.bak'
    } else {
    Write-Host 'Restoring' ([System.IO.Path]::GetFileName($src)) 'to' $dname 'with recovery...'
    $SMORestore.Action = "Database"
    $SMORestore.NoRecovery = $false
    $SMORestore.ReplaceDatabase = $true
    $SMORestore.Database = $dname
    $SMORestore.Devices.AddDevice($src, "File")
    $filearray = $SMORestore.ReadFileList($srv)
    foreach ($file in $filearray){
    $newfile = New-Object Microsoft.SqlServer.Management.Smo.RelocateFile
    $newfile.LogicalFileName = $file.LogicalName
    $newfile.PhysicalFileName = $dst + ([System.IO.Path]::GetFileName($file.PhysicalName))
    $SMORestore.RelocateFiles.Add($newfile) | Out-Null
    $SMORestore.SqlRestore($srv)
    Write-Host ([System.IO.Path]::GetFileName($src)) 'successfully restored to' $dname
    } catch {
    $_.Exception
    if ($Error.Count -gt 0) {
    $error[0] | fl -force
    } #Restore-Database $DSTServer $tmpdbname $bkup $tmpdir $false # - $bkup = .bak not defined | $stby = bool
    and another piece
    function New-Database ($refdb, $dstsrv, $tname, $tdir) {
    Write-Host 'Creating database' $tname 'based on settings from' $refdb.name '...'
    $dstdb = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Database -ArgumentList $dstsrv, $tname
    # Loop through the original db's filegroup to grab all the settings for the new filegroup
    try {
    foreach ($group in $refdb.filegroups) {
    $fg = New-Object -TypeName Microsoft.SqlServer.Management.Smo.FileGroup -ArgumentList $dstdb, $group.name
    $dstdb.FileGroups.Add($fg)
    if ($group.IsDefault -eq $true) {
    $fgdefault = $group.Name
    # Loop through the data files in the filegroup and grab the settings for the new files
    foreach ($file in $group.Files) {
    $datafile = new-object -TypeName Microsoft.SqlServer.Management.Smo.DataFile -ArgumentList $fg, $file.name
    $fg.Files.Add($datafile)
    $file
    $datafile.FileName = $tdir + ([System.IO.Path]::GetFileName($file.FileName))
    $datafile.Size = $file.Size
    $datafile.IsPrimaryFile = $file.IsPrimaryFile
    $datafile.GrowthType = $file.GrowthType
    $datafile.Growth = $file.Growth
    $datafile.MaxSize = $file.MaxSize
    # Loop through the log files in the filegroup and grab the settings for the new files
    foreach ($file in $refdb.LogFiles) {
    $logfile = New-Object Microsoft.SqlServer.Management.Smo.LogFile -ArgumentList $dstdb, $file.name
    $dstdb.LogFiles.Add($logfile)
    $file
    $logfile.Name = $file.name
    $logfile.FileName = $tdir + ([System.IO.Path]::GetFileName($file.FileName))
    $logfile.Size = $file.Size
    $logfile.GrowthType = $file.GrowthType
    $logfile.Growth = $file.Growth
    $logfile.MaxSize = $file.MaxSize
    } catch {
    $_.Exception
    # Create the database
    try {
    $dstdb.Create()
    Write-Host 'Database' $tname 'created successfully'
    } catch {
    if ($Error.Count -gt 0) {
    $error[0] | fl -force
    break
    # Make sure the right filegroup is the default
    If ($dstdb.FileGroups[$fgdefault].IsDefault -ne $true){
    Write-Host 'Setting' $fgdefault 'filegroup as default'
    $fgdef = $dstdb.FileGroups[$fgdefault]
    $fgdef.IsDefault = $true
    $fgdef.Alter()
    $dstdb.Alter()
    } #New-Database $srcdb $DSTServer $tmpdbname $tmpdir

    How were you able to see the tuf in your ldf? Using a simple text editor i'm unable to see mine.
    if you open that file with text editor, you can't use "find" functionality because its not an ASCII text. It took some time for me to locate the text which you are seeing in image which I posted.
    Also how certain are you that it is not possible, do you have experience programming with SMO? Not that I don't believe you but I have spent some time developing a ps script that somewhat hinges on this, so not happy if it was all for not.
    I have NEVER worked with SMO and have no experience. But Since I have spent 10 years of my life working with Microsoft with SQL Server Product support team, I can tell you that it's not stored in any table in database. It's part of LDF and there is no way
    to get that without parsing the LDF file.
    Here is one of the blog written by my friend, who was working in my team.
    http://blogs.msdn.com/b/batala/archive/2011/07/21/how-to-see-the-standby-file-path-when-we-restore-the-database-in-standby-mode.aspx
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Dimension Build File - Member Property Codes

    I am building a Dimension Build File.
    What is the code to create a Shared Member?
    I know the following codes:
    Code
    N Never Share
    O Label Only
    S Stored
    V Dynamic Calc and Store
    X Dynamic Calc
    Or is there a different way to specify a member as a Shared Member in the dimension build file?
    Thanks,
    Dave

    There is no property for a shared member. If you are using a parent/child build method it will automatically load shared members unless you specify don't share. To do a load as a level or generation build, you have to have the file in a particular order and use the dimension build tab of field properties. There is a section in the admin guide that shows you how to do it.
    But for using level builds it would be something like
    Lev 0, Product Lev 1, product Lev 2, Product Lev 1, product
    100-20 100 Products Diet Colas
    Notice how the second lev1 defines the alternate rollup and it would cause a shared member to be created

  • Change in Office Online File URL property?

    When testing our integration with Office Online this morning, it appears something has changed within the /add(<relative_url> endpoint.
    Originally, the URL property of that response gave me a relative path that I could plug into getfilebyserverrelativeurl(<relative_url>). The response I'm now getting back is an absolute path that includes the SharePoint domain.
    According to the documentation:
    Url
    String
    R
    Yes
    Gets a value that specifies the relative URL of the file version based on the URL for the site or subsite.
    The URL property of a File object is generally suppose to be a relative URL -- according to the FileVersion object.
    Can someone confirm this change? And whether or not the URL property is suppose to be absolute or relative? 

    Hi,
    If you want to use the getfilebyserverrelativeurl method to get the all files from a folder in document library, we can use the relative URL of folder.
    Example, we can get all files from the FolderA in Shared Documents(default document library) using this:
    https://sharepoint/_api/web/getfolderbyserverrelativeurl('/Shared%20Documents/FolderA')/files
    More information:
    http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-get-all-the-files-from-the-folder-in-sharepoint-2013/
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.getfilebyserverrelativeurl(v=office.15).aspx
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Received File Name in Map

    How to get the Received File Name(using FILE.ReceivedFileName property)  in BizTalk Map. Kindly provide with suggestions.
    Regards, Vivin.

    try this
    http://blogit.create.pt/blogs/tiagooliveira/archive/2009/02/02/Using-xpath-function-in-orchestrations.aspx
    xpath(msgOut,"string(xpathquery)")=msgIn(FILE.ReceivedFileName)
    You can't promote that field which occurs multiple times so in that case we use xpath()
    Regards

  • Getting incoming filename in error handling orchestration

    I have created an error handling orchestration. It is subscribed to all "FailedMessage" types for a specific port. When I get these messages within my error handling orchestration I need to capture certain information. I'm not seeing a way to capture
    the incoming filename. Certain objects don't seem to be available to me within this orchestration. I can use %SourceFileName% on the outgoing port, but I need to record this info to a database table, so I need this item within the orchestration. 
    Any ideas?
    Thanks.
    Raymond

    You mean Direct bound in the Orchestration?  That, as opposed to Specify Later, would not affect the Message Context in any way, especially the FILE.ReceivedFileName property.
    To test, you can Stop the Orchestration and drop the file.  The Message will Suspend where you can examine the entire Context.

  • OS command  in Communication channel to change property of file...

    Hi All
    Can anybody let me know the OS command (to be written in command line prompt in receiver file channel) to change the property of a file written on Application server.
    A file is getting written on PI application server by a communication channel. Now how can we direct that channel to change the file's property of Read/Write/modify(777) while writing it to the location.
    Thanks in advance.

    Hi
    If you want it dynamically, use a post processing srcipt
    For unix Application system command is
    chmod <file name> 777
    For Windows Application system command is
    ATTRIB [+ R|-R] [A|-A] [ H|-H] [+ S|-S] [d:][path]filename [/S]

  • Java 1.6.0_05 does not recognize first and last property in jnlp file

    Hi
    Has anybody else seen this?
    The jnlp file contains five properties, but the JRE does not recognize the first nor the last property.
    It has been working great since 1.4.2, through 1.5 and 1.6 until 1.6.0_05.
    <property name='bog' value='%2fdata%2fkirkeboeger1892%2f'/>
    <property name='opslag' value='aa001/AB/007/0000a-A.Jpg,aa001/AB/007/0002a-F.Jpg,... </property>
    <property name='sessionId' value='ed0l5n55yu2h04alvqxdpbn3'/>
    <property name='service' value='http://ao.sa.dk/LAView/ImageServer/Service1.asmx'/>
    <property name='titel' value='1908+-+1924%2c+Agerskov%2c+N%c3%b8rre+Rangstrup%2c+Haderslev'/>The 'opslag' property is much longer, so I cut it off to make it more readable.
    Pressing 's' in the console gives me this
    Dump system properties ...
    awt.toolkit = sun.awt.windows.WToolkit
    file.encoding = Cp1252
    file.encoding.pkg = sun.io
    file.separator = \
    http.auth.serializeRequests = true
    https.protocols = TLSv1,SSLv3
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    java.class.path = C:\Program Files\Java\jre1.6.0_05\lib\deploy.jar
    java.class.version = 50.0
    java.endorsed.dirs = C:\Program Files\Java\jre1.6.0_05\lib\endorsed
    java.ext.dirs = C:\Program Files\Java\jre1.6.0_05\lib\ext;C:\Windows\Sun\Java\lib\ext
    java.home = C:\Program Files\Java\jre1.6.0_05
    java.io.tmpdir = C:\Users\MAJ-BR~1\AppData\Local\Temp\
    java.library.path = C:\Program Files\Java\jre1.6.0_05\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Java\jre1.6.0_05\bin;C:\Program Files\Mozilla Firefox;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;"C:\Program Files\Java\jre1.6.0_05\bin"
    java.protocol.handler.pkgs = com.sun.javaws.net.protocol|com.sun.deploy.net.protocol
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.6.0_05-b13
    java.security.policy = file:C:\Program Files\Java\jre1.6.0_05\lib\security\javaws.policy
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Sun Microsystems Inc.
    java.specification.version = 1.6
    java.vendor = Sun Microsystems Inc.
    java.vendor.url = http://java.sun.com/
    java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
    java.version = 1.6.0_05
    java.vm.info = mixed mode, sharing
    java.vm.name = Java HotSpot(TM) Client VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Sun Microsystems Inc.
    java.vm.specification.version = 1.0
    java.vm.vendor = Sun Microsystems Inc.
    java.vm.version = 10.0-b19
    javaplugin.proxy.config.type = direct
    javawebstart.version = javaws-1.6.0_05
    jnlpx.heapsize = 64m,128m
    jnlpx.home = C:\Program Files\Java\jre1.6.0_05\bin
    jnlpx.jvm = "C:\Program Files\Java\jre1.6.0_05\bin\javaw.exe"
    jnlpx.remove = false
    jnlpx.splashport = 49557
    line.separator = \r\n
    opslag = aa001/AB/007/0000a-A.Jpg,aa001/AB/007/0002a-F.Jpg,...
    os.arch = x86
    os.name = Windows Vista
    os.version = 6.0
    path.separator = ;
    service = http://ao.sa.dk/LAView/ImageServer/Service1.asmx
    sessionId = ed0l5n55yu2h04alvqxdpbn3
    sun.arch.data.model = 32
    sun.boot.class.path = C:\Program Files\Java\jre1.6.0_05\lib\resources.jar;C:\Program Files\Java\jre1.6.0_05\lib\rt.jar;C:\Program Files\Java\jre1.6.0_05\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0_05\lib\jsse.jar;C:\Program Files\Java\jre1.6.0_05\lib\jce.jar;C:\Program Files\Java\jre1.6.0_05\lib\charsets.jar;C:\Program Files\Java\jre1.6.0_05\classes;C:\Program Files\Java\jre1.6.0_05\lib\javaws.jar;C:\Program Files\Java\jre1.6.0_05\lib\deploy.jar
    sun.boot.library.path = C:\Program Files\Java\jre1.6.0_05\bin
    sun.cpu.endian = little
    sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
    sun.desktop = windows
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = Cp1252
    sun.management.compiler = HotSpot Client Compiler
    sun.os.patch.level =
    trustProxy = true
    user.country = DK
    user.dir = C:\Users\Maj-Britt\Documents
    user.home = C:\Users\Maj-Britt
    user.language = da
    user.name = Maj-Britt
    user.timezone = Europe/Paris
    user.variant = As one can clearly see, the 'bog' and 'titel' (i.e. first and last) properties are missing, resulting (bad code - I know) in a NullPointerException.

    We also have this problem, but it's not first and last property.
    We have 6 properties, and the 3. property is gone.
    If I download the jnlp file, the property is there, if I choose show jnlp file in "javaws -viewer" it's not there. Only difference between this property and the working properties is length.
    The length is char 255, and the data is base64 encoded.
    I worked fine before upgrading to Java 6 update 5.
    Anyone any ideas?

  • Reading files using wildcard character

    Hi Everyone,
    I currently implemented a servlet that reads contents of a specific directory using File class:
    File contens = new File(directory_path);
    After this I would simply call contents.list(), which would list all of the files in that particular directory. And this works fine but I need to filter some of the files out so I came up with a solution of using a wildcard character:
    File contents = new File(directory_path + "SomeString" + "*");
    I would assume that this should give me all of the file names that begin with "SomeString" but it does not work that well. Instead I get null trying to instantiate a new instance of a File object and NullPointerException when I try to call list() method on it.
    How can I read directory contents if I want only certain file names that begin with "SomeString" for example.
    Any help will be greatly appreciated!
    Thanks in advance,
    Y.M.

    You can create a FilenameFilter and use it like this:
                myFilenameFilter filter=new myFilenameFilter();
                String[] dirArray=new File(myPath).list(filter);
       class myFilenameFilter implements FilenameFilter {
          public boolean accept(File dir, String name) {
             if (name.startsWith(SomeString)) return true; else return false;
    }where SomeString is a globally accessible String.
    V.V.

  • Keeping formating in Property file

    HI,
    I have property file config.property that have a specific formating
    Example:
    # DB
    user = greg
    pass = test
    and I would like to keep it this way after I update the property file using store() method, but what I get is
    user = greg
    pass =test
    It even removes my comments from a file how can I prevent this?
    Thanks for your thoughts.

    Here is a piece of code that will let you save property file with all formating options.
      private void savePropertyFileWithFormatting(String fileNameWithPath, Properties prop) {
            try {
                StringBuffer sb = new StringBuffer ();
                BufferedReader buffIn = new BufferedReader(new FileReader(fileNameWithPath));
                String temp = null;
                while((temp = buffIn.readLine()) != null) {
                    if(temp.startsWith("#") || temp.trim().equals("") ) {
                        sb.append(temp).append("\n");
                        continue;
                    KeyValuePair kv = getKeyValuePair(temp);
                    if(prop.containsKey(kv.key)) {
                        String nValue = (String) prop.get(kv.key);
                        temp = Strings.change(temp, kv.value, nValue);//ViolinStrings or use string.replace
                        sb.append(temp).append("\n");
                buffIn.close();
                BufferedWriter buffOut = new BufferedWriter(new FileWriter(fileNameWithPath));
                System.out.println(sb);
                buffOut.write(sb.toString());
                buffOut.close();
            } catch (Exception e) {
                e.printStackTrace();
        class KeyValuePair {
            public String key = null;
            public String value = null;
         * Get the key and value pair from a string which has the key and the value as 'key = value'
         * @param keyValueString
         * @return
        private KeyValuePair getKeyValuePair (String keyValueString) {
            String[] str = keyValueString.split("=");
            KeyValuePair kv = new KeyValuePair();
            kv.key = str[0].trim();
            kv.value = str[1]==null?"":str[1].trim();
            return kv;
        }

  • Setting up FileName for Output file in SendPort

    Hi - I have a requirement setting up FileName in output file. For instance say, whatever I receive in the 'FathersName' field that Output File should be with that File Name.
    For e.g. if data received in FathersName field is JOHN, output file name should be JOHN.xml
    I am using File Adapters on Receive and send side.
    Can this be achieved just by Messaging Scenario or do I need to implement this using Orchestration ?
    If so, please advise on how to do this ?
    e.
    MBH

    To achieve this, you will have to set your filename value on one of the Context Properties available as a File Adapter macro. For example FILE.ReceivedFileName is mapped to the %SourceFileName% macro.
    You have several options to do this:
    Set FILE.ReceivedFileName in an Orchestration.  It does not have to be Promoted.
    Write the Property ReceivedFileName in namespace
    http://schemas.microsoft.com/BizTalk/2003/file-properties in a Custom Pipeline Component.
    If FathersName can be used in the file name unmodified, you set FathersName as a Promoted Property on the schema and Promote directly to FILE.ReceivedFileName.
    For 1 & 2, you will have to extract FathersName somehow, such as a distinguished field.
    A Custom Pipeline Component or direct Promotion are the only way to achieve this in Messaging only.

  • How to Append date time to the Source File Name in send Port without Orchestration

    Hi,
    I am using the Macro %SourceFileName%_%datetime%.zip in the filename(Send Port).
    say my file name is ABC.zip
    But I am getting the output as ABC.zip_2013T083444
    Please suggest, How to avoid the extension?
    Vignesh S ----------------------------------------------------------- Please use Mark as Answer if my post has solved your problem and use Vote As Helpful if my post was useful.

    The problem here is %SourceFileName% context property would return filename “With” extension. So when you use %SourceFileName%_%datetime%.zip you get FileNameWithExtension_Datetime
    For this you have to handle it either in customer pipeline component or in orceshtration where you have to remove the extension from the Filename.
    Read this post on remove the extension from this file name
    msgOut(FILE.ReceivedFileName) = System.IO.Path.GetFileNameWithoutExtension(msgIn(FILE.ReceivedFileName));
    After this if you use the
    %SourceFileName%_%datetime%.zip macro, you would get the desired output.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

Maybe you are looking for

  • ITunes wont copy to Lacie external hard drive-unknown error-50

    All goes well until I choose "Consolidate Library" from advanced menu in iTunes. Unknown error -50 appears every time. Plenty of free space on the Lacie and I can move single items so no prob with fire wire connection. What can I do ?

  • Moving playlists from one account to another

    Hey, I'm on my admin account right now, and my iTunes is set up on there. I want to switch to a user account and have the same playlist (with ratings and play count intact). Where is the playlist file stored so I can just copy and paste it? (All my s

  • I put in a new hard drive in my pc, how can i import my apps and music from my iphone to my pc

    hi, i am trying to reinstall my apps and music from my iphone to my pc, i just put in a new hard drive.  it is possible or do i have to install each one at a time

  • Good Java System Directory Server book?

    Does anyone know of a good book (or books) for getting up to speed on the Sun Java System stack? I am migrating from Linux and Windows-based apps to the Sun stack and need to hit the books hard to get up to speed, but can't find much of anything newe

  • USB Question

    Back in the crazy days of the late '90s when a young man named Bill Clinton met an even younger woman named Monica Lewinsky, I found myself with a Blue and White G3 and one of the first ever Biondi Blue iMac DVDs... (We used to take it on trips in ou