How to read text file content in portal application?
Hi,
How do we read text file content in portal application?
Can anyone forward the code to do do?
Regards,
Anagha
Check the code below. This help you to know how to read the text file content line by line. You can display as you require.
IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
IResourceContext resourceContext = new ResourceContext(user);
String filePath = "/documents/....";
RID rid = RID.getRID(filePath);
IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
InputStream inputStream = resource.getContent().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = reader.readLine();
while(line!=null) {
line = reader.readLine();
//You can append in string buffer to get file content as string object//
Regards,
Yoga
Similar Messages
-
How to read a file content from portal
Hi experts,
I have a file (xml or xlsx), which i have kept in D drive.
then using GUI_UPLOAD, i have read file content into internal table. then i am proceeding furthur.
but in real, my file will be in portal (means https:\\in.xyz.com\........\TEST.XML
in this case i can not use GUI_UPLOAD.
can any one suggest how can i achieve above. Thanks.
Regards,
Venkata PrasadHi venkata
try this code below
tables: znks_exceldb.
types: begin of wa_input,
emp_id type string,
name type string,
middle type string,
last_name type string,
address type string,
acc_num type string,
mobile type string,
end of wa_input.
data: gt_intern type kcde_intern.
data:gwa_intern type kcde_intern_struc.
data gt_input type table of wa_input.
data gwa_input like line of gt_input.
data it_tab type table of znks_exceldb.
data it_wa like line of it_tab.
constants c_seprator type c value ','.
parameters ex_file type localfile obligatory.
at selection-screen on value-request for ex_file.
call function 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
importing
file_name = ex_file.
start-of-selection.
perform readfile using ex_file.
perform insert.
perform display.
form readfile using ex_file type localfile.
data:lv_filename type rlgrap-filename.
data: lv_index type i.
field-symbols: <> type any.
lv_filename = ex_file.
call function 'KCD_CSV_FILE_TO_INTERN_CONVERT'
exporting
i_filename = lv_filename
i_separator = c_seprator
tables
e_intern = gt_intern
exceptions
upload_csv = 1
upload_filetype = 2
others = 3.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
loop at gt_intern into gwa_intern.
move gwa_intern-col to lv_index.
assign component lv_index of structure gwa_input to <>.
move:gwa_intern-value to <>.
at end of row.
append gwa_input to gt_input.
clear gwa_input.
endat.
endloop.
endform.
form insert.
loop at gt_input into gwa_input.
it_wa-emp_id = gwa_input-emp_id.
it_wa-name = gwa_input-name.
it_wa-middle = gwa_input-middle.
it_wa-last_name = gwa_input-last_name.
it_wa-address = gwa_input-address.
it_wa-mobile = gwa_input-mobile.
it_wa-acc_num = gwa_input-acc_num.
append it_wa to it_tab.
endloop.
insert znks_exceldb from table it_tab accepting duplicate keys.
endform.
form display.
loop at gt_input into gwa_input.
write :/ gwa_input-emp_id,
gwa_input-name,
gwa_input-middle,
gwa_input-last_name,
gwa_input-address,
gwa_input-mobile,
gwa_input-acc_num .
endloop.
endform.
Regards
Niraj Sinha -
Need to read text file content and have to display it in multiline text box
dear all,
Need to read text file content and have to display it in multiline text box.
actually im new to file handling. i have tried up to get_line and put_line.
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
i dont know how to assign this get_line function to text item
pls help me in this regards,Simply write:
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
:block2.t1 := chr(10)||:block2.t1||chr(10)||linebuf;
chr(10) --> is for new line character -
How to read trace file content
Hi,
DB :11.2
How to read trace file content.It's only for ORACLE SUPPORT?
calling
call
entry
argument values in hex
location
type
point
(? means dubious value)
ksedst()+31
call
ksedst1()
000000000 ? 000000001 ?
7FFF19B98CA0 ? 7FFF19B98D00 ?
7FFF19B98C40 ? 000000000 ?
ksedmp()+610
call
ksedst()
000000000 ? 000000001 ?
7FFF19B98CA0 ? 7FFF19B98D00 ?
7FFF19B98C40 ? 000000000 ?
ksfdmp()+21
call
ksedmp()
000000003 ? 000000001 ?
7FFF19B98CA0 ? 7FFF19B98D00 ?
7FFF19B98C40 ? 000000000 ?
kgerinv()+161
call
ksfdmp()
000000003 ? 000000001 ?
7FFF19B98CA0 ? 7FFF19B98D00 ?
7FFF19B98C40 ? 000000000 ?
kgeasnmierr()+163
call
kgerinv()
0069107E0 ? 011F80370 ?
7FFF19B98D00 ? 7FFF19B98C40 ?
000000000 ? 000000000 ?
kssmov()+502
call
kgeasnmierr()
0069107E0 ? 011F80370 ?
7FFF19B98D00 ? 7FFF19B98C40 ?
000000029 ? 0D3F1C600 ?
kfncInitSlavePool() call
kssmov()
0D3F1C5D0 ? 000000000 ?
+203
7FFF19B98D00 ? 7FFF19B98C40 ?
000000029 ? 0D3F1C600 ?
kfncWorkMsgAlloc()+ call
kfncInitSlavePool() 0D3F1C5D0 ? 000000000 ?
83
7FFF19B98D00 ? 7FFF19B98C40 ?
000000029 ? 0D3F1C600 ?
kfncFileUnidentify( call
kfncWorkMsgAlloc() 0D3F1C5D0 ? 7FFF19B99AD0 ?
)+635
7FFF19B98D00 ? 7FFF19B98C40 ?
000000029 ? 0D3F1C600 ?
kffmRequestFree()+1 call
kfncFileUnidentify( 7FFF19B99BC8 ? 7FFF19B99BC0 ?
Br,
RajOne needs to know the meaning of the kernel functions and their working within the oracle database. I guess, oracle support can do the analysis more easily as they have access to the software code as well necessary tools to interpret these internal routines.
Aman.... -
How to read text file line by line...?
how to read text file line by line, but the linefeed is defined by user, return list of string, each line of file is a item of list?
please help me.
Thanks very muchBrynjar wrote:
In Groovy, you would do something like:
linefeed = "\n" //or "\r\n" if the user chose so
lines = new File('pathtofile').text.split("${linefeed}")This is one of the things that has always annoyed me about Sun's sdk, i.e. the lack of easy ways to do things like that. You always end up making your own utilities or use something like Apache's commons.io. Same goes for jdbc and xml - I'll wait for appropriate topics to show how easy that is in Groovy :)I generally agree, but what I really don't like about the Groovy text-file handling niceties: They don't care about encoding/always use the default encoding. And as soon as you want to specify the encoding, it gets a lot more complex (granted, it's still easier than in Java). -
Step by Step"How JSP read text file :
Hi ,
Any one know or have a good site to show step by step how JSP read text file.
TQ.There is no difference Between reading a text file from JSP and reading a text file from Java.
Just follow the same steps for JSP also. -
How to send the file contents in the application server to ftp server
Hi,
how to send the file contents in the application server to ftp server.
regards,
sreeTest SAP FTP functions
DATA: BEGIN OF MTAB_DATA OCCURS 0,
LINE(132) TYPE C,
END OF MTAB_DATA.
DATA: MC_PASSWORD(20) TYPE C,
MI_KEY TYPE I VALUE 26101957,
MI_PWD_LEN TYPE I,
MI_HANDLE TYPE I.
START-OF-SELECTION.
MC_PASSWORD = 'password'.
DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.
*-- FTP_CONNECT requires an encrypted password to work
CALL 'AB_RFC_X_SCRAMBLE_STRING'
ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY
ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD
ID 'DSTLEN' FIELD MI_PWD_LEN.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
USER = 'userid'
PASSWORD = MC_PASSWORD
HOST = 'servername'
RFC_DESTINATION = 'SAPFTP'
IMPORTING
HANDLE = MI_HANDLE
EXCEPTIONS
NOT_CONNECTED = 1
OTHERS = 2.
CHECK SY-SUBRC = 0.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE = MI_HANDLE
COMMAND = 'dir'
TABLES
DATA = MTAB_DATA
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4.
IF SY-SUBRC = 0.
LOOP AT MTAB_DATA.
WRITE: / MTAB_DATA.
ENDLOOP.
ELSE.
do some error checking.
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
HANDLE = MI_HANDLE
EXCEPTIONS
OTHERS = 1.
Execute external commands (FTP Scripts)
The following code shows the syntax of the FM 'SXPG_COMMAND_EXECUTE'. You pass it the external command created within transaction SM69 and it will execute it.
DATA: ld_comline
LIKE sxpgcolist-name,
ld_param LIKE sxpgcolist-parameters,
ld_status LIKE extcmdexex-status,
ld_output LIKE btcxpm OCCURS 0 WITH HEADER LINE,
ld_subrc LIKE sy-subrc.
REFRESH ld_output.
MOVE 'FTP_DATA_IN' to ld_comline. "Maintained using trans SM69
Execute external command, contained in 'ld_comline'
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = ld_comline
additional_parameters = ld_param "Params passed to script
operatingsystem
= 'UNIX'
IMPORTING
status = ld_status
TABLES
exec_protocol = ld_output
EXCEPTIONS
no_permission
= 1
command_not_found
= 2
parameters_too_long
= 3
security_risk
= 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry
= 13
jobcount_generation_error
= 14
OTHERS
= 15.
IF sy-subrc NE 0.
ENDIF. -
How to read text file contain chinese character ?
Hi XI Expert,
I have scenario to read text file contain Chinese Character using sender file adapter. but every i was check from sxmb_moni all the chinese character looks different. and also the target file also i has changes.
Please advise me how to maintaine the chinese character in PI 7.0 SP17.
Thank You and Best Regards
FernandHi,
Refer these threads..
Receiver file adapter corrupting characters
Problem in converting special characters in input text file
Here is one more useful guide..
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42
Regards,
Sarvesh
Edited by: Sarvesh Singh on Nov 17, 2008 3:47 PM -
How to read text file by clicking on text file ?
Hello.. friends
I have made a java editor. I want to pass file name to a function in application by clicking on particular text file.
I assoiciated *.text file type with my application. when I click on text file application is run but I file is not read by my java application.
For example : in windows System all text are oppened in notepad when we click on any text file.
How to do this thing. please suggest me and if possible show me a sample code.
ThanksIf you are doing this in a web application you can set the content type appropriately and the file will open.
If you are doing this standalone you can use the Java RunTime class and execute something like this as the command "notepad.exe c:\\myfile.txt" which should open it up on a Windows operating system. -
Dear Everyone
I have coding below.
{color:#3366ff}*Text file scores.txt*
{color}1 1 1
2 2 2
*{color:#3366ff}Java class jtableone.class{color}*
import javax.swing.*;
public class jtableone extends JApplet {
public static void main(String[] args) throws Exception {
{color:#ff0000}//Read file scores.txt{color}
java.io.File file = new java.io.File("scores.txt");
Scanner input = new Scanner(file);
while (input.hasNext()){
String id = input.next();
String firstname = input.next();
String lastname = input.next();
{color:#ff0000}//System.out.println(id +" "+ firstname +" "+ lastname);
{color}}
input.close();
{color:#ff0000}//Crearte JTable{color}
private String[] columNames =
{"ID", "First Name", "Last Name"};
private Object[][] data = {
//{"12", "Tom", "Clark"},
//{"13", "helen", "Tan"}
{color:#ff0000}//Display JTable{color}
private JTable jTable1 = new JTable(data, columNames);
public jtableone(){
add(new JScrollPane(jTable1));
Can you tell me What i do next?
Create a Object[][] data which can read text file.
Thanks
sevenlonsevenlon wrote:
Can you tell me What i do next?How are we supposed to know? We have no knowledge of what your assignment is.
Create a Object[][] data which can read text file.Then do that. Create the 2D array and store the data in it.
Also when posting code use code tags. Paste code, highlight it and click CODE button. -
How to read entire file content in one XML tag?
Hi,
How can I read entire file content in one XML tag?
What specifications do I need to specify in Sender adapter?
regards,
Anirudh.Hi Chirag,
I am reading a flat file for File to Idoc scenario.
Target Idoc is nested which can not be populated with graphical mapping.
see below post for more detail.
[Mapping flat XML to nested IDOC using node functions |Mapping flat XML to nested IDOC using node functions;
The problem here is I'm not able to identify when to insert context change for child which is repeating for a repeating parent.
Solution therefore, I think is reading entire flat structure in one node and then use UDF to populated intermediate target with proper nesting.
Thats why I need to read entire XML.
regards,
Anirudh. -
How to read text file efficiently?
I use CharBuffer to read text file:
private List<String> load() throws IOException {
final String B = "<BODY>";
final String E = "</BODY>";
List<String> docs = new ArrayList<String>();
for (File file : files) {
FileReader reader = new FileReader(file);
CharBuffer buffer = CharBuffer.allocate(BSIZE);
StringBuilder sb = new StringBuilder();
while (reader.read(buffer) != -1) {
char[] dst = new char[buffer.length()];
buffer.get(dst);
sb.append(dst);
buffer.clear();
String s = sb.toString();
System.out.println(file + ": " + s.length());
int start = 0;
int i, j;
while ((i = s.indexOf(B, start)) != -1) {
j = s.indexOf(E, i + B.length());
docs.add(s.substring(i + B.length(), j));
start = j + E.length();
//System.out.printf("%d %d %d%n", i, j, start);
return docs;
}The file size is 1324350, but the code say it is 772802.
What's wrong with this code?
I want to read text file as quickly as possible.
Is this code the right way to read file?
Should I use FileReader or nio Channel and ByteBuffer?
Any suggestions are welcome!You are reading the file as if it were encoded in UTF-16. Each character uses two bytes so you have half the number of characters as you had bytes.
The following code reads an entire file in one hit.
public static String readText(File file) throws IOException {
byte[] bytes = new byte[(int) file.length()];
DataInputStream dis = new DataInputStream(new FileInputStream(file));
try {
dis.readFully(bytes);
} finally {
dis.close();
return new String(bytes, "UTF-8"); // or whatever your file encoding is.
}But you can still have less characters than bytes if there are any non ASCII-7 characters. -
HI,,,How to read text file from my emulators root
hi friends,
Actully i m having problem with file connection i.e. i cant read text file from my root of the emulator.....
i have tried like this...
plz help me out
String uri = "file:///C:/WTK22/appdb/DefaultColorPhone/filesystem/root1/New Folder/main.txt";
InputConnection conn = (InputConnection)Connector.open( uri,Connector.READ );
InputStream in = conn.openInputStream();
conn.close();
for(int j=0;j<12;j++)
ch=in.read();
str.append((char)ch);
par1=str.toString();
in.close();
screen4.append(par1);
display.setCurrent(screen4);still its not working.........
String uri = "file:///C:/WTK22/appdb/DefaultColorPhone/filesystem/root1/readme.txt";
FileConnection conn = (FileConnection)Connector.open( uri,Connector.READ);
InputStream in = conn.openInputStream();
conn.close();
String ss="";
String str1="";
int ch=0;
byte b[]=new byte[753];
ch=in.read(b,0,753);
str1= new String(b,0,ch);
ss=str1.substring(493,501);
screen4.append(ss);
display.setCurrent(screen4);
}catch(IOException io){} -
How to read a file content in a ordinary java program
Please help me is there is any method is available to read the content of the file.I am asking in pure java not in the servlets.Guys please help me.I got structed here
Reading a text file in the systems character encoding: use the class java.io.FileReader. You can wrap a BufferedReader around it to get better performance (and a simple way to read lines)
Reading a text file in another character encoding: use FileInputStream and convert it to a reader with:
InputStreamReader reader = new InputStreamReader(fileStream, encoding);
where encoding is the character encoding as a String (like "Cp850" or "UTF-16LE"). Again, you can wrap a BufferedReader around that reader.
Reading a binary file: open a FileInputStream to the file and just read the bytes from it. You can use BufferedInputStream for better performance and DataInputStream to get a simple way to read primitive types like double and char.
Please help me is there is any method is available to
read the content of the file.I am asking in pure java
not in the servlets.Guys please help me.I got structed
hereAren't servlets pure Java? -
How to read text file with big5 into db
hi,
how can i use UTL_FILE package to
read a text file with big5 characters and insert into db?
my oracle charset is AL32UTF8.
thx a lot!Thx for yr answer!!!
I have followed and it works.
However, I got another problem with HKSCS. When the text file contained HKSCS, the store procedure also treats it as Big5 and when I select it out, the character was not the orginal one.
Please suggest if you have any ideas.
Many Thanks!!!
Maybe you are looking for
-
When I click send link my yahoo programme will not let me acess yahoomail
when I click send link my btinternet mail facility no longer works and just keeps asking for my password. when I give it it has no email pop up to send link and this process is just endless. I have had to use the computer default now but I would like
-
PU Ordered quantity exceeded by 123,456
Hi, I have selected the default value for 'Propose all items' in the MIGO settings option, to enable early GR against a Scheduling Agreement. Now, When i try to do a GR with MIGO i am getting the following error message: PU Ordered quantity exceeded
-
What happened to the ArchWiki?
Hi All. What happened to the old style ArchWiki main page? Previously it was very easy to find crucial articles especially for the new users but also for me. Now the main content is hidden among other minor articles and quite difficult to find. Maybe
-
What version of IE is required for BPELConsole?
Using the latest version of BPEL process manager I am seeing a lot of javascript errors in the BPEL console. e.g. From the console, click on an in-flight instance and try to click on any of the left hand side tabs I get an error dialog that says: "In
-
LabVIEW PID Code explained?
Hi NI Community, I'm working on understanding the code behind the LabVIEW PID. First, let me say that YES I understand the theory of a classical PID control and understand how Kp, Ki, and Kd should affect my system. I'm interested in some of the unde