How to read a file and pickup some information from a file
Hai all,
I wrote a beloe program to read a file and write it into another file
import java.io.*;
public class Rdata {
/** Creates a new instance of Rdata */
public Rdata() {
public static void main(String a[])throws Exception
FileReader fr=new FileReader("c:\\java\\attach\\attach2\\resume1.doc");
FileWriter fw=new FileWriter("C:\\java\\attach\\abc2.doc");
char ch;
int i;
while((i=fr.read())!=-1)
ch=(char)i;
fw.write(ch);
fw.close();
This program reads the content from resume1.doc and write it into abc2.doc . But in my project I want to read the resume1.doc and and write only peace of information like "keyskills are java,jsp,javamail"
I mean how to read the entaire file and how to write into another file whisc i require
Thanks®ards
radhs
http://java.sun.com/docs/books/tutorial/essential/io/
Similar Messages
-
I want to read and use some informations from a excel file
To test a graphic, i need to take a lot of numbers in a excel file...
but i dont know how to open and read this file but i dont know how...
thx for your help...Hello,
You can open, read, and even write excel files (if you write a file with extension .xls, windows will interpret it as an excel file be default) using the File I/O VIs in LabVIEW. To extract the data, all you really need to realize is that spreadsheets programs like excel store data with the following basic rules:
1. the entire spreadsheet is really just a large string - to read them, you just have to know the data you read is stored based on rules 2 and 3; to write them you just have to conform to rules 2 and 3.
2. cells in a given row are delimited by tabs (usually by default) and sometimes commas (but usually only if you set this specifically in the spreadsheet program)
3. rows are delimited by end of line characters, which will usually be one carriage return and one linefeed character in that order on windows.
In fact, for writing spreadsheet strings (which can be opened in excel) from LabVIEW, check out the Array to Spreadsheet String and Spreadsheet String to Array functions in the String Palette. That is, if you imagine the excel spreadsheet as a 2D array, those functions will essentially convert between the large string, and a 2D array in LabVIEW containing the values you would see in excel's corresponding cells.
I have attached a program that will use the array to spreadsheet string function to write an excel file containing those values - it will be named test.xls and should be on your C: drive directly. A good exercise to get started would be to write a VI using similar (some inverse) functions to read that string, and convert it back to an array.
I hope this helps!
Best Regards,
JLS
Best,
JLS
Sixclear
Attachments:
Simple Write Spreadsheet String to Excel File.vi 25 KB -
How to open a popup and get some data from a model class
Hi experts,
mi problem is the next.
I am opening a popup from a view that is controlled by a controller named identificador.do, the controller class is z_identity_cl.
the window that is opened is other view controlled by nocupentes.do, with a controller class, z_nocupantes_cl.
In the do_init event of the z_nocupantes class i have added the next code:
<i> DATA: cl_parent TYPE REF TO Z_IDENTtity_CL.
Recuperamos el atributo parent
cl_parent ?= me->m_parent.
model is the class i want to recover, it is defined in the attibutes of the class z_identity_cl
model ?= cl_parent->get_model( 'mo' ).</i>
When i open the popup i get the next error:
<i>BSP exception : the object numero_ocup.htm(this is the page i want to open) in URL sap/ZHR_PDWEB_GDPT/numero_ocup.htm is a view. Initialize the controller.</i>
what do i have to do?
any help?
thanks in advanceHi Eduardo,
you should be calling the Controller in the URL not the View. after calling the controlles in the URL create the view in the DO_REQUEST of the Controller. This should resolve the issue.
In the the DO_INIT define the Parent class of the Controller.
METHOD do_init.
DATA: lr_my_parent TYPE REF TO zcl_hr_main_control.
* set (MVC) model
lr_my_parent ?= me->m_parent.
set_model( model_instance = lr_my_parent->model
model_id = 'Z' ).
me->model = lr_my_parent->model.
ENDMETHOD.
method DO_REQUEST.
* datadeclaration
DATA: abs TYPE REF TO if_bsp_page.
* if input is available, dispatch this input to subcomponent.
* this call is only necessary for toplevel controllers.
dispatch_input( ).
* if any of the controllers has requested a navigation,
* do not try to display, but leave current processing
IF is_navigation_requested( ) IS NOT INITIAL.
RETURN.
ENDIF.
* output current view (create, set attibutes, and call)
abs = create_view( view_name = 'to_disp.htm' ).
* set attribute model if needed
abs->set_attribute( name = 'model' value = model ).
* call master views
call_view( abs ). "calls itself
endmethod.
Cheers
Amandeep -
SIU - Apply Computer Name and Local Hostname settings from a file
I am setting up a workflow to image corporate computers and wanting to know how the "Apply Computer Name and Local Hostname settings from a file" works in the Apply System Configuration Settings task.
We bind the computer to AD and OD and we have a specific naming convention for certain departments and trying to automate the entire imaging process.
Would this be something that can be done with SIU?Well, maybe there's a bug in the latest version (10.5.3) of SIU as this is not what is happening.
It doesn't seem to matter what I specify for the name parameters I end up with a Bonjour name of ".local".
I put in a line of the form <Mac Address><TAB>tom<TAB>dick<TAB>harry into the text file used by the Apply System Configuration Settings Action.
and end up with hostname = tom, Computer Name = dick and Bonjour Name = .local
I'm building the NetInstall image on a new iMac running 10.5.3 booted out of a second partition and create the image from the main boot partition (also 10.5.3). I then copy the image to my server (10.5.3) and make a second iMac boot up from the NetInstall image.
For what it is worth the Workflow Actions I am using are:
Define Image Source
+ NetInstall
Source: Macintosh HD
Filter Clients by MAC Address
+ Allow
<List of MAC Addresses>
Enable Automated Installation
+ On Volume Named: Macintosh HD
+ Erase before installing
+ Primary Language: English
Apply System Configuration Settings
+ Apply Computer Name and Local Hostname settings from a file: <FILE>
Add Packages and Post-Install Scripts
+ Shell Script [Doesn't work - we're discussing in it in another thread]
Create Image
In: Public
Named: NetInstall Classroom
Volume Name: Classroom iMacs
Index: 1 -
I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?
Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.
-
After reinstalling CS6 the bridge photo downloader isn't able to read raw files and fails to convert the raw files to DNG. Previously downloaded raw files, now DNG, open up successfully in Camera Raw 7. How do I get the photo downloader to read and convert raw files. MacBook Pro with Snow Leopard. No such problem before this reinstallation.
You should install Camera Raw 4.6.
Visit this page and follow the instructions carefully:
PC: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4040
Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4039
-Noel -
How to read and write a data from extrenal file
Hi..
How to read and write a data from extrenal file using Pl/sql?
Is it possible from Dyanamic Sql or any other way?
Reagards
Rajuutl_file
Re: How to Create text(dat) file.
Message was edited by:
jeneesh -
How to read the date and time information of a file by labview
how to read the date and time information of a file by labview? for example, created time and modified time.
Solved!
Go to Solution.if you need to know the last modification date of file:-
"Functions->File I/O->Advanced File Functions->File/Directory Info.vi"
This vi returns the value of file's last modification date. This is returned as U32 number. To see it in MM/DD/YY format you must create the indicator, right-click on it and select "Format & Precision" item from drop-down menu. Then select "Time and Date" format there.
Thanks as kudos only -
How to create a file and store its contents into another file?
Hi,
I'm having some trouble trying to create a code where I have to to create a file and store its contents into another file?
I read the API, but I'm not certain how this file thing works.
Here's my code so far:
public static void main(String[] args) throws Exception
File file = new File("tasks.txt");
if (file.exists())
System.out.println("File already exists");
System.exit(0);
Scanner scan = new Scanner(System.in);
Scanner scan2 = new Scanner(System.in);
//Scans the input line by line
scan.useDelimiter("\\n");
//Scans the input by tabs
scan2.useDelimiter("\\t");
PrintWriter outputs = new PrintWriter("newtasks.txt");
outputs.print("ok");
outputs.println(3);
outputs.close();
}I managed to change my text into uppercase, but how do I store the uppercase content into another file.
-So this is what I did so far, I took a text file and modified its strings to uppercase.
-Now I need to put those modified strings into another text file, is there a way where I can do that with my current code?
-I already tried printwriter, but it doesn't seem to work
public static void main(String[] args)throws IOException
//Task[] oneHundredTasks = new Task[100];
String uppercase;
String combine;
Scanner scan = null;
FileInputStream in = null;
FileOutputStream out = null;
PrintWriter output = null;
try
scan = new Scanner(new BufferedReader(new FileReader("tasks.txt")));
scan.useDelimiter("\\n");
scan.useDelimiter("\\t");
while (scan.hasNext())
if(!scan.hasNext())
scan.next();
combine = scan.next();
uppercase = combine.toUpperCase();
System.out.println(uppercase);
finally
if (scan != null)
scan.close();
//The program will try the input and output files
try
in = new FileInputStream("tasks.txt");
out = new FileOutputStream("newtasks.txt");
int c;
//The number "-1" is used to indicate that it has reached the end of the stream.
while ((c = in.read()) != -1)
out.write(c);
finally
if (in != null)
in.close();
if (out != null)
out.close();
} -
How could i parse string and link its model with my files in eclipse project?
How could i parse string and link its model with my files in eclipse project?, as i read that we dont have to use standalone mode while working with eclipse projects.
Example of what i want to do:
I have file1.dsl in my project which contains some statements but the declaration of these statements are not in another file, i need to put them only in my codeHi Stefan,
I have eclipse project contains 2 files, file1.dsl and file2.dsl, you can see the contents of the files below.
file1.dsl contains some statements as shown below and file2.dsl contains the declarations of the variables. (like in C++ or Java we have declarations and usage)
At this step file1.dsl and file2.dsl will be parsed successfully without any errors.
Lets imagine that we will delete this project and will create another one and the new project will contain only file1.dsl (which contains the usage)
At this step this file (file1.dsl) will contains some errors after parsing it, because we are using variables without declarations.
So what i need is to parse the content of file2.dsl directly without adding this file to the project.
I need to add the content of file2.dsl directly as a string in the code and parse it. just like that ( "int a;int b;" )
And link file1.dsl with the model generated after parsing my string
file1.dsl
a++;
b++;
file2.dsl
int a;
int b;
Thanks -
I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is just a plain photoshop file, a watermark is added, then save as jpeg - the jpeg is saved to a different folder than the original photoshop file.) It happens for about 10 of 30/40 files approximately . Thank you, Kathryn
I believe I have figured it out - I need to flatten the image, even though there are no layers except for layer 0, first.
-
How to run the report and show the output in excel file
salam
how to run the report and show the output in excel file,
how to run the report and print the o/p via printer
how to run the report and send the o/p via mail
thank u allHi,
There are Parameters DESTTYPE, DESFORMAT and DESNAME. You can set these parameters to get as you want.
1) Output in Excel File
ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'FILE');
ADD_PARAMETER(PL_ID, 'DESFORMAT', TEXT_PARAMETER, 'DELIMITED');
ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<file_name>.XLS');2) output to printer
ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'PRINTER');
ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<printer_name>');3) Email - Have to configure SMTP and all. ( i didn't checked it)
ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'MAIL');
ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<email_id>');Regards,
Manu.
If this answer is helpful or correct, please mark it. Thanks. -
On Adobe Acrobat Pro, how do I take a PDF file and convert it into an excel file?
I am not sure how to take a PDF file and change it into an excel file. I have Adobe Acrobat Pro. Thanks!
Using Acrobat XI Pro.
File - Save As Other - Spreadsheet - Microsoft Excel Workbook
Be well... -
Adobe reader XI crash and hangs when open the pdf file
After update the adobe reader xi 11.0.10, the reader always crashes and hangs when open the pdf file. Please help me how to do.
Ben Leung wrote:
HThis situation is started after I clear the pop up advertisement.
What kind of advertisement? In Adobe Reader? Can you post a screenshot of that: https://forums.adobe.com/thread/1070933
Regarding the crash, can you try disabling Protected Mode through the registry: download, unzip, then run the registry script https://files.acrobat.com/a/preview/49eeb48b-07c5-4502-984c-8a25259914fa -
Read a excel file and split its sheets to seperate file ?
Dear all :
How to split a excel file into several file, each have one sheet.my code is as below,thanks:
import org.apache.poi.hssf.usermodel.*;
import java.io.*;
import java.util.*;
import org.apache.poi.poifs.filesystem.*;
public class Extractxls {
public static void main(String[] args) throws Exception
try {
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(args[0]));
HSSFWorkbook wb = new HSSFWorkbook(fs);
int sheetCount = wb.getNumberOfSheets();
System.out.println(sheetCount);
try {
while(sheetCount > 0) {
sheetCount--;
HSSFWorkbook wb1 = new HSSFWorkbook();
HSSFSheet s = wb1.createSheet();
String sheetName = wb.getSheetName(sheetCount);
HSSFSheet sheet = wb.getSheet(sheetName);
// HSSFSheet sheet = wb.getSheetAt(sheetCount);
System.out.println(sheet.toString());
s = sheet;
FileOutputStream fileOut = new FileOutputStream("atest" + sheetCount + ".xls");
wb.write(fileOut);
fileOut.close();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
} catch (Exception e) { e.toString();}The HSSFWorkbook class is part of the POI project:
http://jakarta.apache.org/poi/
Regards,
Dave Gilbert
JFreeChart Project Leader
I understand poi porject, my problem is that POI can not read a excel file and split its sheets into seperate file (each have one sheet) ?Does any one know how to do it.
Maybe you are looking for
-
Reciever JDBC Adapter error (Oracle)
Hi, I am trying FILE-XI-JDBC Scenario to get data loaded in Oracle. I have configured the reciever adapter in Communication Channel but while sending the message i am getting the following error: <b>com.sap.aii.af.ra.ms.api.DeliveryException: JDBC Ad
-
Production Portal is not starting...
Hello All, I have a very serious problem with my production portal. Every after 2-3 days, the portal doesn't start properlly in the morning, It shows page can not be displayed. The only thing we can do for this is to restart the server. Can somebody
-
Meet The Expert with Joe Ambeault only 15 minutes left!!!
Hi, Everybody! Just wanted you to know Joe will be here live on this Meet The Expert board for 15 more minutes and then will be back at 8:00PM EDT to chat with you some more! Thank you for the great participation!
-
Retaining the cursor on a Text Field when error on the field
Hi, We have a requirement, where when we tab out of a text field, the data entered gets validated and exceptions are caught using array list and then thrown on top of the page. However, we have a requirement, that on tab out, the cursor should remain
-
We have an ipod version 4.2.1 model PB528ll. We can not get the ipod to play songs in sequence. Welcome suggestioins. Thomas 28