File name from n.txt to (n+1).txt
I am supposed to write a program that reads from n.txt and writes into (n+1).txt everytime the program starts. Help me
I'm not really sure what you're saying. Can you post your code so far?
When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
Similar Messages
-
hi ,
there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
but i had to write a dynamic code which can get the file name from any given path.Smoke me a kipper, I'll be back before breakfast.
SQL> var extended_filepath varchar2(128)
SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
PL/SQL procedure successfully completed.
SQL> select instr(:extended_filepath, '/', -1)
2 from dual
3 /
INSTR(:EXTENDED_FILEPATH,'/',-1)
21
SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
2 from dual
3 /
SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
file.txt
SQL> Cheers, APC -
Retrieve file name from full file path
I am trying to retrieve a file name from a path (ex. c:\temp\tes.txt) using the following code, but it is given me an error of "The method split(String) in the type String is not applicable for the arguments (char).
{code}
String filepath = item.getName();
String[] buf = filepath.split('/');
String filename = buf[buf.length-1];
{code}
I tried to use double quote instead of single quote, but it is not returning anything.
{code}
String[] buf = filepath.split("/");
{code}
Anyone knows why? Thanks.How is this related to JDBC?
Anyway, is the path separator actually a forward slash? Isn't it a backward slash?
If you're using Apache Commons FileUpload (which I guess, the 'item.getName()' is recognizeable), then just read their FAQ: [http://commons.apache.org/fileupload/faq.html#whole-path-from-IE]. -
SSIS - creating part of the file name from an id in the database
I am trying to figure out how to pull an "id" from my data source to include in the file name. Right now the file name created looks like customer_002_timestamp.txt. I need to add the id to the file name and I need to grab it at the time I get
the data, so then the file name becomes customer_002_id_timestamp.txt.
My data source is Oracle and I am using Attunity, so I do not have the capability of using the resultset found in the SQL Task because I have to use the data task.
Has anyone ever extracted an id from a query against Oracle using the Attunity connector to add as part of the file name? If so, how would I add that to my control flow task?
Thanks in advance for any assistance.Is it a static id value you want
Then you can just use a SSIS variable to hold value from resultset in execute sql task
Then inside your data flow you can use an expression for setting value of another variable which can be used for setting filename in your destination task. The expression will include logic to concatenate id variable also which we populated in the previous
step.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Seperating file name from the path
Hi,
im trying to validate the file path and trying to seperate file name from the path.
for eg.
if the path is f:\sapfilepath\doc\ext.txt
need to get f:\sapfilepath\doc im looking for a dynamic way of doing this.
your help will be appreciated.
Regards,
ravi.Hi,
Use the function module
SO_SPLIT_FILE_AND_PATH
Thanks,
Naren -
How to delete file names from Adobe Reader list
How can I delete file names from the Adobe Reader list? I have deleted the file & it's empty, but deleted file names remain in my list & it's very annoying. I can't seem to find an option anywhere to delete the file names.
Thanks for the answer, I will try this & post my results with this method. I have set the amount to zero, & it seems if I want to put back valid files into my list I first need to find them in another file in my pc, such as documents, open them in Adobe Reader, & then then they will reappear in the Adobe Reader list. Is this correct? Thank you!
This seems to be the case, you need to restore each file you want in your list one by one by accessing them elsewhere on your pc, & then you must open them with Adobe Reader to have files reappear in your Adobe Reader list. However, this seems to be a tedious process if you only want to delete one obsolete file from your list by first emptying the list & rebuilding it file by file. It works, but I'm wondering if there is a more sensible & efficient way to do this? -
How can I assign image file name from Main() class
I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
Here is the Main class
import org.me.lib.MyJNIWindowClass;
public class Main {
public Main() {
public static void main(String[] args) {
MyJNIWindowClass mw = new MyJNIWindowClass();
mw.s = "clock.gif";
And here is the library class
package org.me.lib;
public class MyJNIWindowClass {
public String s;
ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
public MyJNIWindowClass() {
JLabel jl = new JLabel(image);
JFrame jf = new JFrame();
jf.add(jl);
jf.setVisible(true);
jf.pack();
I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
Thank you.Your problem is one of timing. Consider this simple example.
public class Example {
public String s;
private String message = "Hello, " + s;
public String toString() {
return message;
public static void main(String[] args) {
Example ex = new Example();
ex.s = "world";
System.out.println(ex.toString());
}When this code is executed, the following happens in order:
1. new Example() is executed, causing an object to constructed. In particular:
2. field s is given value null (since no value is explicitly assigned.
3. field message is given value "Hello, null"
4. Back in method main, field s is now given value "world", but that
doesn't change message.
5. Finally, "Hello, null" is output.
The following fixes the above example:
public class Example {
private String message;
public Example(String name) {
message = "Hello, " + name;
public String toString() {
return message;
public static void main(String[] args) {
Example ex = new Example("world");
System.out.println(ex.toString());
} -
Retreiving the file names from directory inside another directory from application server
Hi,
I had a problem in retreiving the file names from a directory inside another directory.
I tried using the FM's SUBST_GET_FILE_LIST, RZL_READ_DIR_LOCAL and EPS_GET_DIRECTORY_LISTING
But here I am getting only one directory details.
Actually my file is located a directory inside one more directory and one more directory and inside the files are located.
i.e total 3 directories inside the 3rd one my files are there.
I need to read the latest file name in the directory.
So that i can do some manipulation after getting the file name.
Is there option like OPEN DATASET , READ DATASET and CLOSE DATASET?
Can anyone please let me know How can i acheive this one.
Regards
RamHi Ram,
Following thread can be helpful for you, were it shows in the tables structure rsfillst a field RSFILLST-TYPE whether its a directory or file..........
http://scn.sap.com/thread/865272
thanks and regards,
narayan -
How to get the target file name from an URL?
Hi there,
I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
System.out.println("Opening connection to " + url + "...");
// Copy resource to local file
InputStream is = url.openStream();
FileOutputStream fos=null;
String fileName = null;
StringTokenizer st=new StringTokenizer(url.getFile(), "/");
while (st.hasMoreTokens())
fileName=st.nextToken();
System.out.println("The file name will be: " + fileName);
File localFile= new File(System.getProperty("user.dir"), fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} catch (Throwable e) {
e.printStackTrace();
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
}Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
System.out.println("Opening connection to " + url + "...");
// Copy resource to local file
InputStream is = url.openStream();
FileOutputStream fos=null;
String fileName = null;
StringTokenizer st=new StringTokenizer(url.getFile(), "/");
while (st.hasMoreTokens())
fileName=st.nextToken();
System.out.println("The file name will be: " + fileName);
File localFile= new File(System.getProperty("user.dir"), fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} catch (Throwable e) {
e.printStackTrace();
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
}Do you know how I can do that.
Thanks for your help
// JB
Edited by: jb-from-sydney on Feb 9, 2010 10:37 PMThanks for your answer.
By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
* Download locally a file from a given URL.
* @param url - the url.
* @param destinationFolder - The destination folder.
* @return the file
* @throws IOException Signals that an I/O exception has occurred.
public static final File downloadFile(URL url, File destinationFolder) throws IOException {
URLConnection urlC = url.openConnection();
InputStream is = urlC.getInputStream();
FileOutputStream fos = null;
String fileName = getFileName(urlC);
destinationFolder.mkdirs();
File localFile = new File(destinationFolder, fileName);
fos = new FileOutputStream(localFile);
try {
byte[] buf = new byte[1024];
int i = 0;
while ((i = is.read(buf)) != -1) {
fos.write(buf, 0, i);
} finally {
if (is != null)
is.close();
if (fos != null)
fos.close();
return localFile;
* Returns the file name associated to an url connection.<br />
* The result is not a path but just a file name.
* @param urlC - the url connection
* @return the file name
* @throws IOException Signals that an I/O exception has occurred.
private static final String getFileName(URLConnection urlC) throws IOException {
String fileName = null;
String contentDisposition = urlC.getHeaderField("content-disposition");
if (contentDisposition != null) {
fileName = extractFileNameFromContentDisposition(contentDisposition);
// if the file name cannot be extracted from the content-disposition
// header, using the url.getFilename() method
if (fileName == null) {
StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
while (st.hasMoreTokens())
fileName = st.nextToken();
return fileName;
* Extract the file name from the content disposition header.
* <p>
* See <a
* href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
* //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
* information regarding the headers in HTML.
* @param contentDisposition - the content-disposition header. Cannot be
* <code>null>/code>.
* @return the file name, or <code>null</code> if the content-disposition
* header does not contain the filename attribute.
private static final String extractFileNameFromContentDisposition(
String contentDisposition) {
String[] attributes = contentDisposition.split(";");
for (String a : attributes) {
if (a.toLowerCase().contains("filename")) {
// The attribute is the file name. The filename is between
// quotes.
return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
// not found
return null;
} -
Flat file name from Sender Side Dynamically into subject of Receiver Mail
Hi All,
I am Using a file to Mail Scenario, My requirement is to get dynamically the file name from flat file of the Sender Side into Subject of Receiver Mail Adapter and attachment of file from the Sender Side. Can anyone help me out.
Thanks in AdvanceHi....
You can write udf in the message mapping to get the Dynamic file name and map that to the subject of the receiver mail.
DynamicConfiguration conf = (DynamicConfiguration) param.get(
StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
// read value
String Filename = conf.get(KEY_FILENAME);
Regards,
Leela -
How to get the file name from Oracle B2B 10g
Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
I tried using the b2b.filename property in the receive activity and it is not getting the file name.
<sequence name="main">
<receive name="Receive_Note" partnerLink="GetB2BNote"
portType="ns1:Dequeue_ptt" operation="Dequeue"
variable="Receive_Note_Dequeue_InputVariable"
createInstance="yes">
<bpelx:property name="b2b.fileName" variable="WriteFileName"/>
</receive>
</sequence>
Can you help me to get the file name from Oracle b2b 10g ?
Thanks,
b2b userHi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
I tried using the b2b.filename property in the receive activity and it is not getting the file name.
<sequence name="main">
<receive name="Receive_Note" partnerLink="GetB2BNote"
portType="ns1:Dequeue_ptt" operation="Dequeue"
variable="Receive_Note_Dequeue_InputVariable"
createInstance="yes">
<bpelx:property name="b2b.fileName" variable="WriteFileName"/>
</receive>
</sequence>
Can you help me to get the file name from Oracle b2b 10g ?
Thanks,
b2b user -
Same file name from sender to receiver file adapter with out using UDF
Hi All,
I am working on FILE TO FILE. My requirement is same file name from sender to receiver file adapter. Is it possible to do using only Adapter Specific message properties? i mean with out using UDF.
Thanks
KarthikHi,
>>>Is it possible to do using only Adapter Specific message properties?
yes
just enable Adapter Specific message properties in sender and receiver channel for file name
and you're done
Regards,
Michal Krawczyk -
File name from an attribute of an element of the payload
Dear Experts,
Could you suggest the syntax for specifying the file name from a variable in the file receiver communication channel? I need to grab the file name from an ATTRIBUTE of an element of the payload.
Thanks a lot.
Example: Need to pass the attribute "descReceipt" of the element "promotionEvent" to the variable in the following payload:
<?xml version="1.0" encoding="UTF-8"?>
<promotionExport>
<promotionEvent eventIdentifier="30" status="A" descReceipt="FILE1">The scenario is IDOC to FILE. I need to get the value of the receiving partner.
The message header has the node "DynamicConfiguration". Please see the xml below. I need to grab the key RCVPRN (0000002104) from this and pass as the file name in the receiver file adapter.
How do I setup my receiver file adapter for this? I tried changing the values for the variable, and also enabling the adapter specific message attributes. No solution yet.
<SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPOR">LXDCLNT250</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPRT">LS</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPRN">0000002104</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPOR">SAPLCD</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPRN">LCDCLNT220</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="CIMTYP" />
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="IDOCTYP">WPDBBY01</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="MESTYP">WPDBBY</SAP:Record>
<SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPRT">KU</SAP:Record>
</SAP:DynamicConfiguration> -
Can we possible to retrive the file name from the directory...?
Can we possible to retrive the list of files or file names from the directory...?
The directory called create or replace directory [directory_name] as ....Yeah, yeah its very good example for this scenario.
I agree. But, I want to learn about Java based PL/SQL code development for that just I am asking any link for this kind of material.....:-) -
Capture File name from the messageFileUpload bean
Hi All,
Please let me knw, how to capture the file name from the messageFileUpload bean. I have attached a blobdomain type view attribute to this bean. I am able to get the file content , but not able to capture the file name entered.
Please help me ...very urget...
Regards,
TarunAny solution for this?
Thanks
Santosh
Maybe you are looking for
-
OS update 10.2.1.217​9
After the update 10.2.1.2179 was installed on my BB Z10 I have numerous troubles: (1) Many of the contacts in my address book which had the same office phone number were linked. I found one contact with 521 links. Could not unlink them. Ended up dele
-
3 modem ADSL 2 and Linksys E-4200 ?
I would like use one Linksys E-4200 or more with 3 modem adsl 2 in order to extend the wifi zone and the trafic, for 10 users. I need advices, please.
-
If the CD/DVD player is not found in either the BIOS or Device manager is the problem in the motherboard? if it is besides getting an external CD/DVD player, is there any other solutions? Thanks
-
Why is iTunes showing foriegn characters as boxes?
My iTunes has foriegn characters as boxes everytime I attempt to enter them. This seems to be a new occurance for me. Any help?
-
Transaction Management for Nested Application Module
Hi I'm using Jdev 11.1.2.0 I am having nested Application Module. In that I want to separate view object data need to commit without commit the root application module view object. Is it possible. Kindly reply me.