Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Frits Walraven
  • Himai Minh

io problem

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers,
i have one problem with , i want to read one file , the contents of the file is like this,
file name: 1.txt
name age date of birth
x 21 82
y 23 80
i want to read the file then i, want to manipulate age like 21+3 and want to write in new file 2.txt after manipulation.
please help me
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry i just had a few minutes and i could complete u'r pprogram by hardcoding the value of the character position ..u could use a while or for loop for this instead, when u use io it reads character by character so u should add add digit wise
hope this helps ..u should be able to fine tune this program i'm givin below for u'r use
import java.util.*;
public class readwrite
public static void main(String[] ar)
// initailize buffer reader
BufferedReader in = new BufferedReader(new FileReader("1.txt"));
//initialize buffer writer
BufferedWriter out = new BufferedWriter(new FileWriter("2.txt"));

String str;
String str1;
//read from file 1.txt

//return ascii value for char at position 3
int tt=((int)str.charAt(3)+4);
//cast to chatr and get the value from ascii
char c=(char)tt;
//replace string with the specific value
//write into 2.txt

catch(IOException e)


today's feeble attempt to support the empire
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic