<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ไอเอินบล๊อก &#187; PathReplace</title>
	<atom:link href="http://www.iearn.in.th/tag/pathreplace/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iearn.in.th</link>
	<description>Just Play and Just Knowledge</description>
	<lastBuildDate>Fri, 05 Aug 2011 15:10:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Java covert Linux path to Windows path</title>
		<link>http://www.iearn.in.th/2008/04/24/java-covert-linux-path-to-windows-path/</link>
		<comments>http://www.iearn.in.th/2008/04/24/java-covert-linux-path-to-windows-path/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 15:53:43 +0000</pubDate>
		<dc:creator>nolifelover</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[convertWindowsPath]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[linuxPath]]></category>
		<category><![CDATA[pathConfig]]></category>
		<category><![CDATA[PathReplace]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windowsPath]]></category>

		<guid isPermaLink="false">http://www.jaideawhosting.com/nolifelover/?p=123</guid>
		<description><![CDATA[สำหรับช่วงนี้ห้องผมจะมีโจทย์จากกอาจาร์มาประมาณ 1 ข้อต่อวันครับเพื่อฝึกทักษะการเขียนโปรแกรมของพวกเราหลังจากที่ ได้เขียน Android Application ไม่เข้าตากรรมการ สำหรับโจทย์วันแรกคือการเขียนเจ้า Java เพื่อแปลง path ของ linux ไปเป็น windows ครับ เราดูโจทย์กันดีกว่าครับ input /home/user/images/xxx.jpg config /home/user =&#62; c:\user output c:\user\images\xxx.jpg โดยเจ้าโปรแกรมที่เขียนต้องสามารถ maintain และ reuse ได้โดยเจ้าโปรแกรมที่เขียนได้ประมาณนี้ครับ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [...]]]></description>
			<content:encoded><![CDATA[<p>สำหรับช่วงนี้ห้องผมจะมีโจทย์จากกอาจาร์มาประมาณ 1 ข้อต่อวันครับเพื่อฝึกทักษะการเขียนโปรแกรมของพวกเราหลังจากที่ ได้เขียน Android Application ไม่เข้าตากรรมการ สำหรับโจทย์วันแรกคือการเขียนเจ้า Java เพื่อแปลง path ของ linux ไปเป็น windows ครับ เราดูโจทย์กันดีกว่าครับ</p>
<p>input /home/user/images/xxx.jpg<br />
config /home/user =&gt; c:\user<br />
output c:\user\images\xxx.jpg</p>
<p><span id="more-123"></span></p>
<p>โดยเจ้าโปรแกรมที่เขียนต้องสามารถ maintain และ reuse ได้โดยเจ้าโปรแกรมที่เขียนได้ประมาณนี้ครับ</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */</span>
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">softwareskill</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author mLri
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> PathReplace <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003399;">String</span> windowsPath<span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> linuxPath<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        PathReplace path <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PathReplace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;c:<span style="color: #000099; font-weight: bold;">\\</span>thai&quot;</span>, <span style="color: #0000ff;">&quot;/home/new&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> testPath <span style="color: #339933;">=</span> path.<span style="color: #006633;">parsePath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/home/new/images/xxx.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;testPath is &quot;</span><span style="color: #339933;">+</span>testPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> PathReplace<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> pathConfig, <span style="color: #003399;">String</span> pathConvertTo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        windowsPath <span style="color: #339933;">=</span> pathConfig<span style="color: #339933;">;</span>
        linuxPath <span style="color: #339933;">=</span> pathConvertTo<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> parsePath<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> path<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> newPath <span style="color: #339933;">=</span> path.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span>linuxPath, windowsPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> convertWindowsPath <span style="color: #339933;">=</span> newPath.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span>,<span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//System.out.println(&quot;newPath is &quot; + newPath);</span>
        <span style="color: #666666; font-style: italic;">//System.out.println(&quot;windowsPath is &quot;+windowsPath);</span>
        <span style="color: #000000; font-weight: bold;">return</span> convertWindowsPath<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p class="sayac_bilgi">8 views</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iearn.in.th/2008/04/24/java-covert-linux-path-to-windows-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

