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?
Similar Messages
-
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/write file on remote server in java
Hi All,
How To read/write file on remote server in java? I mean using URL - http://www.xyz.com can I right file to that perticular server.
Thanks in advanceIf your server support a means of uploading files you can.
A popular means is [http://en.wikipedia.org/wiki/WebDAV]
However, by default web server don't allow you upload files, its usually something you need to configure or install.
I suggest you have a look at your web servers documentation. -
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,
AnaghaCheck 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 -
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 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 -
How to read a file in another location using Java ?
Hi all,
i suppose the below code reads my file 'ridata.dat' when it is in the same folder as my java class file.
How can i read it from a different location?
---------------------------------------------------------------FileRead.java---------------------------------------------------------------
import java.io.*;
class FileRead
public static void main(String args[])
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("ridata.dat");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
---------------------------------------------------------------FileRead.java---------------------------------------------------------------
Thanks in Advance,
LakshmaTry with JFileChooser
JFileChooser fileChooser = new JFileChooser();
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
System.out.println(selectedFile.getName());
}Thanks,
Avin -
How to read a file content for editing?
Now i am using FileInputStream to read its content by bytes. How do i read the content line by line as string so that i am able to do some editing using replace().
public String load() throws FileNotFoundException, IOException {
BufferedReader r = new BufferedReader(new FileReader(new File(this.getClass().getResource(filename).getPath())));
String s = r.readLine();
StringBuffer result = new StringBuffer();
while (s != null) {
result.append(s + "\n");
s = r.readLine();
r.close();
return result.toString(); -
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 pmd files on mac?
How to read pmd files on mac?
There is no native support to open PageMaker documents on the Mac. I would check to see what PageMaker document versions that InDesign CS6 can open, ether on Mac or PC.
Adobe still has the trial of PageMaker 7 for Windows (Adobe link) and PM7 PDF, which you could install in Boot Camp, or Mac Virtual Machine in Windows 7.
I just checked the latest release of LibreOffice, and there is no support for PageMaker anything.
zamzar dot com does not support .pmd content. -
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 the file from a folder.
Hi All,
How to read the file from a folder or directory from the non sap server / remote server.
Regards
Sathisopen dataset filename for input in text mode
encoding default.
filename is character type variable with the destination filename.
Edited by: Jino Augustine on Apr 19, 2010 1:31 PM -
How to read .xml file from embedded .swf(flash output) in captivate
I have been trying to read .xml file from the .swf (Flash output) that is embedded within the captivate file but no luck yet . Please if anyone got any clue on how get this thing done using Action script 3.0 then let me know. I am using Adobe Captivate 5.5 at present and Flash CS 5.5.
I am well aware about how to read .xml file through action script 3.0 in flash but when insert the same flash in captivate and publish nothing comes in captivate output. I would higly appreciate if anyone could help me out with that.
Here is is graphical demonstration of my query :
Message was edited by: captainmkvHi Captainmkv,
Does the information in this post cover what you're trying to do: http://forums.adobe.com/message/5081928#5081928
Tristan, -
How To Read RTF file in JAVA? Using iText?
How To Read RTF file in JAVA? Using iText?.....
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.rtf.*;
public class RTF3 {
public static void main(String[] args) {
// System.out.println("This example generate a RTF file name Sample.rtf");
// Create Document object
Document myDoc = new Document();
try {
// Create writer to listen document object
// and directs RTF Stream to the file Sample.rtf
RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
// open the document object
myDoc.open();
// Create a paragraph
Paragraph p = new Paragraph();
p.add("Helloworld in Rtf file..amazing isn't");
// Add the paragraph to document object
myDoc.add(p);
catch(Exception e) {
System.out.println(e);
//close the document
myDoc.close();
Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
at com.lowagie.text.Document.open(Unknown Source)
at view.RTF3.main(RTF3.java:23)
CAN you HELP me?import com.lowagie.text.Document;
import com.lowagie.text.rtf.parser.RtfParser;
import java.io.FileInputStream;
String inputFile = "sample.rtf";
Document document = new Document();
document.open();
RtfParser parser = new RtfParser(null);
parser.convertRtfDocument(new FileInputStream(inputFile), document); -
How to read the files in different directories
how to read the files in different directories here directory names will change dynamically under root node.
let me say
rootnode---->subnode1
>subnode2
>subnode3
>subnode n
how to specify these in file adapter.Hi
look at this thread your problem is solved here
File Adapter
Regards
Abhishek
Edited by: Abhishek Agrahari on Dec 16, 2008 11:37 AM
Maybe you are looking for
-
Hi all, My Old Laptop that had my Itunes, has died a death and cannot be saved. How can I save or access all my music and apps now? Can I set up a new Itunes account? Also I am getting an upgrade to Iphone 4 ,can I transfer all my music and apps on t
-
Why doesn´t the plugins show up after installation and restart?
In previous versions I have never had plugin problems, but now I have updated to version 13 of Elements and even after several reinstallations of both this program and the plugins these never show up. The possibility to choose a map manually works, b
-
Declining a meeting invitation
I have raised this with several of RIM's partners and see that it keeps appearing in each OS update. When a user declines an eVite on Blackberry mail, his name is permanently removed from the host's list of invitees, and the user no longer receives a
-
A passcode screen has appeared, but i didn't set one up
the 'enter passcode' screen is blocking me from using my ipad. i didn't set it up, what happened and how can I disable it?
-
Installing 10.4.4 in a proper way
Hello to all who have problems with installing the new OS X update (10.4.4) First of all: Don't hesitate and take your time, don't hurry up (excuse my bad English). Look at MacFixIt, they brought an excellent upgrade procedure recommendation at: http