Click here to Skip to main content
15,908,842 members
Home / Discussions / Java
   

Java

 
AnswerRe: Object parsing non-static Pin
jschell21-Aug-12 8:40
jschell21-Aug-12 8:40 
QuestionIs it a bug or featuere Pin
Amarap18-Aug-12 0:58
Amarap18-Aug-12 0:58 
AnswerRe: Is it a bug of featuer Pin
Manfred Rudolf Bihy18-Aug-12 2:11
professionalManfred Rudolf Bihy18-Aug-12 2:11 
AnswerRe: Is it a bug of featuer Pin
Gerben Jongerius18-Aug-12 2:12
Gerben Jongerius18-Aug-12 2:12 
AnswerRe: Is it a bug of featuer Pin
Eddy Vluggen18-Aug-12 2:28
professionalEddy Vluggen18-Aug-12 2:28 
AnswerRe: Is it a bug of featuer Pin
TorstenH.18-Aug-12 3:22
TorstenH.18-Aug-12 3:22 
AnswerRe: Is it a bug or featuere Pin
Gowtham Gutha15-Nov-12 7:25
Gowtham Gutha15-Nov-12 7:25 
Questionproblem while updating a file Pin
Namdeo Badhe17-Aug-12 7:07
Namdeo Badhe17-Aug-12 7:07 
suppose i have a text file as data.txt has following content such as

12.12.12.12 "www.google.com"|"www.yahoo.com"|"www.rediffmail.com"
13.13.12.12 "www.yahoo.com"|"www.rediffmail.com"|"www.google.com"|"www.google.com"
14.14.12.12 "www.yahoo.com"|"www.rediffmail.com"|"www.yahoo.com"


i have another text file as token.txt has following content such as

"www.google.com" 100
"www.yahoo.com" 200
"www.rediffmail.com" 300


i want to make new file as result.txt that should contain the following data such as

12.12.12.12 100 200 300
13.13.12.12 200 300 100 100
14.14.12.12 200 300 200

my code is as follows







import java.util.*;
import java.io.*;

public class UpdateFile
{

public static void main(String[] args) throws Exception
{



BufferedReader in=new BufferedReader(new FileReader(new File("data.txt")));
PrintWriter out=new PrintWriter(new FileWriter(new File("result.txt")));


String str="";


while((str=in.readLine())!=null)
{
ArrayList<string> url=new ArrayList<string>();
StringBuilder sq = new StringBuilder();
String parts[]=str.split("\\s+");

BufferedReader in2=new BufferedReader(new FileReader(new File("token.txt")));

String str2="";


String matchstr= parts[1];

String mm[]=matchstr.split("\\|");

for(int h =0;h<mm.length;h++){
while((str2="in2.readLine())!=null){
" string="" urltoken[]="str2.split("\\s+");
" if(mm[h]="=" null="" ?="" urltoken[0]="=" :="" mm[h].equals(urltoken[0])){

="" if(urltoken[1].tostring()!="null){
" url.add(urltoken[1].tostring()+"?");
=""
="" }
="" url.add(str2);
=""

="" if(url.size()="">0)
out.print(parts[0]+" "+" ");

for(int i=0;i<url.size();i++)
{
="" if(url.size()="">0)
{

out.print(url.get(i));


}}

url.clear();
out.println();
out.flush();


}

}
}
Answerdouble post Pin
TorstenH.17-Aug-12 9:00
TorstenH.17-Aug-12 9:00 
Generalproblem while updating a text file in java Pin
Namdeo Badhe17-Aug-12 6:45
Namdeo Badhe17-Aug-12 6:45 
GeneralRe: problem while updating a text file in java Pin
Richard MacCutchan17-Aug-12 6:59
mveRichard MacCutchan17-Aug-12 6:59 
QuestionMessage Removed Pin
16-Aug-12 6:53
Member 936232116-Aug-12 6:53 
QuestionSwing Pin
Joshua Waring15-Aug-12 23:53
Joshua Waring15-Aug-12 23:53 
AnswerRe: Swing Pin
pasztorpisti16-Aug-12 0:28
pasztorpisti16-Aug-12 0:28 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 0:45
Joshua Waring16-Aug-12 0:45 
AnswerRe: Swing Pin
pasztorpisti16-Aug-12 0:55
pasztorpisti16-Aug-12 0:55 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 1:22
Joshua Waring16-Aug-12 1:22 
GeneralRe: Swing Pin
pasztorpisti16-Aug-12 1:50
pasztorpisti16-Aug-12 1:50 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 2:02
Joshua Waring16-Aug-12 2:02 
GeneralRe: Swing Pin
pasztorpisti16-Aug-12 2:12
pasztorpisti16-Aug-12 2:12 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 3:57
Joshua Waring16-Aug-12 3:57 
GeneralRe: Swing Pin
pasztorpisti16-Aug-12 4:08
pasztorpisti16-Aug-12 4:08 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 4:11
Joshua Waring16-Aug-12 4:11 
SuggestionRe: Swing Pin
pasztorpisti16-Aug-12 4:24
pasztorpisti16-Aug-12 4:24 
GeneralRe: Swing Pin
Joshua Waring16-Aug-12 2:13
Joshua Waring16-Aug-12 2:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.